Asked by Lauren
Create the logic for a program whose main() method prompts a user for 1000 numbers and stores them in an array.
Pass the array to a method that reverses the order of the numbers.
In the main() method, display the numbers.
Pass the array to a method that reverses the order of the numbers.
In the main() method, display the numbers.
Answers
Answered by
Steve
Try something like this:
main() {
int x[1000],y[1000],i;
for (i=0;i<1000;i++) {read x[i]}
y = rev(x,1000);
for (i=0;i<1000;i++) {printf("%d ",x[i]}
}
int *rev(*int,n) {
int y[1000],i;
for (i=0,n--;i<1000;i++,n--) {y[i] = x[n-i];
return y;
}
main() {
int x[1000],y[1000],i;
for (i=0;i<1000;i++) {read x[i]}
y = rev(x,1000);
for (i=0;i<1000;i++) {printf("%d ",x[i]}
}
int *rev(*int,n) {
int y[1000],i;
for (i=0,n--;i<1000;i++,n--) {y[i] = x[n-i];
return y;
}
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.