Swap two elements using the concept of pointers Program in C

WAP to swap two elements using the concept of pointers.

#include<stdio.h>
void swap(int *, int *); //prototype of the function   
int main()  
{  
    int a = 10;  
    int b = 20;   
    printf("Before swapping the values in main a = %d, b = %d\n",a,b);
    swap(&a,&b);  
    printf("After swapping values in main a = %d, b = %d\n",a,b); 
}  
void swap (int *a, int *b)  
{  
    int temp;   
    temp = *a;  
    *a=*b;  
    *b=temp;  
    printf("After swapping values in function a = %d, b = %d\n",*a,*b);  
}


Output:

Before swapping the values in main a = 10, b = 20
After swapping values in function a = 20, b = 10
After swapping values in main a = 20, b = 10
b. tech. bca c language tutorial learn c language mca study c language