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