/* This program read n value into array calculate reverse array and display all data in reverse order */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,a[100],temp;
clrscr();
printf(“Total value in the array\n”);
scanf(“%d”,&n);
printf(“Enter %d value \n”,n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
printf(“\nOriginal List is:\n”);
for(i=0;i<n;i++)
printf(“%5d”,a[i]);
/* Reverse Logic */
for(i=0;i<n/2;i++)
{
temp = a[i];
a[i]=a[n-1-i];
a[n-1-i] =temp;
}
printf(“\nReverse List is:\n”);
for(i=0;i<n;i++)
printf(“%5d”,a[i]);
getch();
}
Latest posts by Mohit Arora (see all)
- MongoDB Operators Tutorial – What are Different Operators Available? - October 5, 2019
- MongoDB Projection Tutorial : Return Specific Fields From Query - March 9, 2019
- MongoDB Index Tutorial – Create Index & MongoDB Index Types - July 6, 2018