123. WAP to swap 1st and 2nd half of given array
#include<stdio.h>
int
a[10]={1,2,3,4,5,6,7,8,9,10},ele,i,j;
void
main()
{
ele=sizeof(a)/sizeof(a[0]);
for(i=0,j=ele/2;j<ele;i++,j++)
{
a[i]=a[i]^a[j];
a[j]=a[i]^a[j];
a[i]=a[i]^a[j];
}
for(i=0;i<ele;i++)
printf("%d ",a[i]);
printf("\n");
}
Comments
Post a Comment