read array of integers and print in reverse order

Write a program read in an array of integers and print its elements in reverse order.


Source code:

#include<stdio.h>
#include<conio.h>
void main()
{
	int i,a[10];
	clrscr();
	for(i=0;i<10;i++)
	{
		printf("Enter the array element: ");
		scanf("%d",&a[i]);
	}
	for(i=0;i<10;i++)
	{
		printf("Array element is: %d \n",a[9-i]);
	}
	getch();
}

Output:

Enter the array element: 1
Enter the array element: 2
Enter the array element: 3
Enter the array element: 4
Enter the array element: 5
Enter the array element: 6
Enter the array element: 7
Enter the array element: 8
Enter the array element: 9
Enter the array element: 0

Array element is: = 0
Array element is: = 9
Array element is: =8
Array element is: =7
Array element is: =6
Array element is: =5
Array element is: =4
Array element is: =3
Array element is: =2
Array element is: =1

Leave a Reply

Your email address will not be published. Required fields are marked *