Write a program that reads in 10 integer numbers from the keyboard using scanf.
ID: 3832393 • Letter: W
Question
Write a program that reads in 10 integer numbers from the keyboard using scanf. Your program should then print out the numbers in reverse order. Your program should store the 10 numbers into a one-dimensional array. Remember, scanf wants you to provide it an address expression. Do you see that this problem requires you to "hold" all the numbers at once before you can generate the answer? This was not the case when we computed the sum of some numbers. To compute the sum we did not need to "hold" the numbers so an array was not needed or wanted. But, here it is.Explanation / Answer
Code :
#include <stdio.h>
int main(void) {
int a[10];
printf("Enter 10 integer numbers");
int i;
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf(" The array in reverse order : ");
for(i=9;i>=0;i--)
printf("%d ",a[i]);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.