Advertisement
rony-Rony_05

problem 2

Jul 2nd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int swap(int *,int *);
  4. int main()
  5. {
  6.  
  7.     int n1,n2;
  8.     printf("\n\n Function : swap two numbers using function :\n");
  9.     printf("------------------------------------------------\n");
  10.     printf("Input 1st number : ");
  11.     scanf("%d",&n1);
  12.     printf("Input 2nd number : ");
  13.     scanf("%d",&n2);
  14.  
  15.     printf("Before swapping: n1 = %d, n2 = %d ",n1,n2);
  16.  
  17.     swap(&n1,&n2);
  18.     printf("\nAfter swapping: n1 = %d, n2 = %d \n\n",n1,n2);
  19. }
  20.     int swap(int *p,int *q)
  21. {
  22.     int tmp;
  23.     tmp = *p;
  24.     *p=*q;
  25.     *q=tmp;
  26.     return swap;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement