3.22.2012

Array in reverse order

Q. Write a C program to display the array in reverse order.


Ans.


/*c program for display the array in reverse order*/
#include<stdio.h>
#include<conio.h>
#define SIZE 50
int main()
{
 int arr[SIZE];
 int i,index,tmp,num;
 printf("Enter total number of element in array : ");
 scanf("%d", &num);
 for(i=0; i<num; i++)
 {
  printf("Enter %d element : ",i+1);
  scanf("%d", &arr[i]);
 }
 printf("\n-- Array in reverse order --\n\n");
 for(i=0; i<num; i++);
 for(i--; i>=0; i--)
    printf("\t%d\n",arr[i]);
 getch();
 return 0;
}


/************* Output *********************/
Screen shot of  display array in reverse order




Related Programs:

  1. How to create array in C?
  2. How to calculate length of array?
  3. Insert new element in array
  4. Delete an exist element in array
  5. Example of array C program

No comments:

Post a Comment