Question: Write a C program to take two array of 5-5 elements and swap elements of Array A to Array B.
#include
int main() {
int arrA[5],arrB[5],i,temp;
printf("Enter elements of Array A\n");
for(i=0;i<5;i++)
{
scanf("%d",&arrA[i]);
}
printf("Enter elements of Array B\n");
for(i=0;i<5;i++)
{
scanf("%d",&arrB[i]);
}
printf("After Swapping\n arrayA\t arrayB \t \n");
for(i=0;i<5;i++)
{
temp=arrA[i];
arrA[i]=arrB[i];
arrB[i]=temp;
printf("\t %d \t %d \t \n",arrA[i],arrB[i]);
}
return 0;
}
Output:
Enter elements of Array A
2
3
4
5
6
Enter elements of Array B
7
8
9
10
11
After Swapping
arrayA arrayB
7 2
8 3
9 4
10 5
11 6
Comments
Post a Comment