By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

How to output an array backward ?

P: 4
The question asking me to output backward, is it the same meaning as inverse output??

this is what I've done so far :
Expand|Select|Wrap|Line Numbers
  1. /*Q3) Develop a C program that inputs a list of
  2. numbers, letting the user decide how many.
  3. Output the list backwards, but only output
  4. numbers greater than 20?*/
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int main()
  10. {
  11.  
  12.     int i,N;
  13.     int array[200];
  14.  
  15.     printf("Input The Size of the array you wish:\n");
  16.     scanf("%d",&N);
  17.     printf("Input the array of size %d:\n",N);
  18.     for (i=0;i<N;i++)
  19.     scanf("%d",&array[i]);
  20.  
  21.     printf("*****************\n");
  22.     printf("The New array With backward order is:\n");
  23.     for(i=N-1;i>=0;i--)
  24.     if(array[i]>20)
  25.     printf("%d\n",array[i]);
  26.  
  27.     return 0;
  28. }
  29.  
  30.  
  31.  
any suggestion ?
Thanks
Nov 17 '10 #1

✓ answered by donbock

Develop a C program that inputs a list of numbers, letting the user decide how many. Output the list backwards, but only output numbers greater than 20.
My interpretation of these requirements is that your program must allow the user to enter any amount of numbers; then the program must print those same numbers back in reverse order (newest numbers first), being careful not to print any numbers less than or equal to 20.

That is, if the user enters these numbers:
  • -10
  • 0
  • 10
  • 100
  • 20
  • 30
  • 40
  • 50

The program must print:
  • 50
  • 40
  • 30
  • 100

It looks to me like your program does this. Are you having any problems with it? By the way, you ought to verify that 'N' is not greater than 200 (the size of 'array').

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 2,400
Develop a C program that inputs a list of numbers, letting the user decide how many. Output the list backwards, but only output numbers greater than 20.
My interpretation of these requirements is that your program must allow the user to enter any amount of numbers; then the program must print those same numbers back in reverse order (newest numbers first), being careful not to print any numbers less than or equal to 20.

That is, if the user enters these numbers:
  • -10
  • 0
  • 10
  • 100
  • 20
  • 30
  • 40
  • 50

The program must print:
  • 50
  • 40
  • 30
  • 100

It looks to me like your program does this. Are you having any problems with it? By the way, you ought to verify that 'N' is not greater than 200 (the size of 'array').
Nov 17 '10 #2

P: 4
My problem is that i need to know if they mean by backward the same as inverse order, but from your words I realized that it is the same.
Also You are right that I should verify that "N" is not greater than 200.
thanks A lot
Nov 17 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.