-->
Showing posts with label elements in reverse order. Show all posts
Showing posts with label elements in reverse order. Show all posts

program to enter some elements and display that in opposite order.

//array program to input elements and to display them in reverse order
  #include<stdio.h>
  #include<conio.h>
  void main()
  {
  clrscr();
  int arr[100];      // array declaration with maximum size 100
  int size;     // size to be used to input elements
  int i;            //variable declaration
  printf("enter size of elements \n");//displays message
  scanf("%d",&size);                  //gets input for array size
  for(i=0;i<size;i++)
   {                            //loop execution
     printf("enter elements\n");//displays message
     scanf("%d",&arr[i]);      //gets input for  array entered by user

   }
   printf("elements, in reverse order, are\n");
   for(i=size-1;i>=0;i--)
   {
   printf("%d\n",arr[i]);       // displays  elements
   }
   getch();

   }
--------------------------------------------------
logics:-
1)declare an array of  partiular size.
2)input elements for this using loop.
3)to display, use loop from given size-1 to 0 location (look above)
that's all
more, u can understand from side by description given in program
-------------------------
screen shot

output: