Advertisement
Md_hosen_zisad

array swap

Nov 5th, 2017
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int j, i;
  5.     printf("Enter number ::");
  6.     int n;scanf("%d",&n);
  7.     int arr1[10];
  8.     printf("Enter 1st array ::");
  9.    for(i=0; i<n;i++)
  10.    {
  11.        scanf("%d",&arr1[i]);
  12.    }
  13.     int arr2[10];
  14.      printf("Enter 2nd array ::");
  15.    for(i=0; i<n;i++)
  16.    {
  17.     scanf("%d",&arr2[i]);
  18.    }
  19. printf("After swaping 1st Array :");
  20. for(i=0 ; i<n;i++)
  21. {
  22.     arr1[i]=arr1[i]+arr2[i];
  23.     arr2[i]=arr1[i]-arr2[i];
  24.     arr1[i]=arr1[i]-arr2[i];
  25.     printf("%d ",arr1[i]);
  26. }
  27. printf("\n");
  28. printf("After swaping 2nd Array ::");
  29. for(i=0 ; i<n;i++)
  30. {
  31. printf("%d ",arr2[i]);
  32.  
  33.  }   return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement