Write a program to copy an array to the another in reverse order.

#include<stdio.h>

main()
{ int n,i,j, a[100],b[100];
printf("\nEnter the dimension:: ");
scanf("%d",&n);

printf("\nEnter the elements of the array:: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);

for(i=n-1,j=0;i>=0 && j<n;i--,j++)
b[j]=a[i];


printf("\nFirst Array:: ");
for(i=0;i<n;i++)
printf("%d ",a[i]);

printf("\nReversed Array:: ");
for(i=0;i<n;i++)
printf("%d ",b[i]);
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s