Write a program to reverse an array or string using swapping - 99webcode
#include<stdio.h>
int main()
{
int n,i,j,temp;
printf("enter the size of array\n");
scanf("%d",&n);
printf("enter elements \n");
int arr[n];
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
temp=arr[0];
arr[0]=arr[n-1];
arr[n-1]=temp;
for(i=0;i<n;i++)
{
printf("%d \t",arr[i]);
}
}
output :
enter the size of array
3
enter elements
1
2
3
3 2 1
[Finished in 7.56s]