Advertisement
rana1704

Every Pair exchange

Sep 14th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int a[100],n,i;
  5.     int temp;
  6.  
  7.     printf("Enter total number of even elements: ");
  8.     scanf("%d",&n);
  9.  
  10.     for(i=0;i < n;i++)
  11.     {
  12.         scanf("%d",&a[i]);
  13.     }
  14.     for(i=0;i<n;i+=2)
  15.     {
  16.         temp=a[i];
  17.         a[i]=a[i+1];
  18.         a[i+1]=temp;
  19.     }
  20.  
  21.     printf("Every Pair exchange \n");
  22.     for(i=0;i<n;i++)
  23.     {
  24.         printf("%d\n",a[i]);
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement