Monday 14 September 2015

WAP to reverse an array

 #include<stdio.h>
#include<conio.h>
void main()
{int n,c,d,a[10],b[10];
printf("\nenter the elements of array");
scanf("%d",&n);
printf("enter the array elements\n ");
for(c=0;c<n;c++)
scanf("%d",&a[c]);
for(c=n-1,d=0;c>=0;c--,d++)
b[d]=a[c];
for(c=0;c<n;c++)
a[c]=b[c];
printf("rev\n");
for(c=0;c<n;c++)
printf("%d\n",a[c]);
getch();
}

No comments:

Post a Comment