Swapping of two arrays in C ! 


#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;
}

Output:


C Programming - Array swapping

04 Aug 2015

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top