Write A C Program For Swapping Of Two Arrays

Write a c program for swapping of two arrays


Solution :

#include<stdio.h>
int main(){
  int a[10],b[10],c[10],i;
  printf("Enter First array->");
  for(i=0;i<10;i++)
  scanf("%d",&a[i]);
  printf("\nEnter Second array->");
  for(i=0;i<10;i++)
            scanf("%d",&b[i]);
  printf("Arrays before swapping");
  printf("\nFirst array->");
  for(i=0;i<10;i++){
            printf("%d",a[i]);
  }
  printf("\nSecond array->");
  for(i=0;i<10;i++){
            printf("%d",b[i]);
  }
  for(i=0;i<10;i++){
            //write any swapping technique
            c[i]=a[i];
            a[i]=b[i];
            b[i]=c[i];
  }
  printf("\nArrays after swapping");
  printf("\nFirst array->");
  for(i=0;i<10;i++){
            printf("%d",a[i]);
  }
  printf("\nSecond array->");
  for(i=0;i<10;i++){
            printf("%d",b[i]);
  }
  return 0;
}


More C Program :


  1. Write a c program for swapping of two arrays
  2. c program to swap two numbers using arrays
  3. swapping of two numbers using array in c
  4. write a c program to merge two arrays
  5. write a c program to merge two arrays into a sorted third array
  6. write a c program to swap two numbers without using the third variable
  7. write a c program to swap two numbers using pointers
  8. write a c program to swap two numbers using function
  9. write a c program to swap two numbers using call by value and call by reference


Learn More :