#include<stdio.h>
#include<conio.h>
main()
{
int n, c, j, temp, a[100];
printf("Enter the number of elements in array\n");
scanf("%d",&n);
printf("Enter the array elements\n");
for ( c = 0 ; c < n ; c++ )
scanf("%d",&a[c]);
if( n%2 == 0 )
c = n/2 - 1;
else
c = n/2;
for ( j = 0 ; j < c ; j++ )
{
temp = a[j];
a[j] = a[n -j - 1];
a[n-j-1] = temp;
}
printf("Reverse array is\n");
for( c = 0 ; c < n ; c++ )
printf("%d\n", a[c]);
getch();
return 0;
}
#include<conio.h>
main()
{
int n, c, j, temp, a[100];
printf("Enter the number of elements in array\n");
scanf("%d",&n);
printf("Enter the array elements\n");
for ( c = 0 ; c < n ; c++ )
scanf("%d",&a[c]);
if( n%2 == 0 )
c = n/2 - 1;
else
c = n/2;
for ( j = 0 ; j < c ; j++ )
{
temp = a[j];
a[j] = a[n -j - 1];
a[n-j-1] = temp;
}
printf("Reverse array is\n");
for( c = 0 ; c < n ; c++ )
printf("%d\n", a[c]);
getch();
return 0;
}
No comments:
Post a Comment
Please comment bellow. Share your knowledge