Sunday 15 March 2015

Program to read and reverse an array Using C

# include <stdio.h>
# include <conio.h>

void main()
{
int a[20], i, n ;
clrscr() ;
printf("Enter the limit : ") ;
scanf("%d", &n) ;
printf("\nEnter the elements :\n\n") ;
for(i = 0 ; i < n ; i++)
scanf("%d", &a[i]) ;
printf("\nThe reversed array is :\n\n") ;
for(i = n - 1 ; i >= 0 ; i--)
printf("%d\t", a[i]) ;
getch() ;
}

RUN 1 :
~~~~~~~
Enter the limit : 5
Enter the elements :
20 30 50 10 40
The reversed array is :
40 10 50 30 20

No comments:

Post a Comment