Advertisement
apl-mhd

swap

Feb 16th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. /*
  5. void swap(int *p, int *q){
  6.    
  7.     int temp;
  8.    
  9.     temp =*p;
  10.    
  11.     *p = *q;
  12.     *q =temp;
  13.    
  14.    
  15.     } */ /*swap function using pointer*/
  16.    
  17.    
  18. void swap(int p[], int q[]){
  19.    
  20.     int temp;
  21.     temp =p[0];
  22.     p[0] = q[0];
  23.     q[0] =temp;
  24.    
  25.     }
  26.  
  27. int main(int argc, char **argv)
  28. {
  29.     int number[10]={1,2,3,4,5,6};
  30.    
  31.     //int a,b;
  32.     //a=10;b=20;
  33.     swap(&number[0], &number[5]);
  34.    
  35.     printf("%d %d",number[0],number[5]);
  36.  
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement