Reverse array
Write a program to copy the contents of one array into another in the reverse order.
#include
#include
void main(void)
{
int arr[10],i,*fp;
for(i=0;i<10;i++)
{
printf("Enter the %d element:",i+1);
scanf("%d",&arr[i]);
}
fp=&arr[9];
for(i=0;i<10;i++)
{
printf("%d",*fp--);
}
getch();
}
#include
#include
void main(void)
{
int arr[10],i,*fp;
for(i=0;i<10;i++)
{
printf("Enter the %d element:",i+1);
scanf("%d",&arr[i]);
}
fp=&arr[9];
for(i=0;i<10;i++)
{
printf("%d",*fp--);
}
getch();
}
Comments
Post a Comment