C Programming
Computer Programming

Program in C to swap two number using pointer



Write a Program in c to swap two number using pointer

\* C Program to to swap two number using pointer *\

# include < stdio.h >
int   main( )
{

int   a, b, temp  ;
int   *p1, *p2  ;
printf(" Enter the first number : ") ;
scanf("%d ", & a) ;
printf("\n Enter the second number : ") ;
scanf("%d ", & b) ;
printf("\n Two Number before swapping :%d, %d ", *p1, *p2) ;
temp = *p1  ;
*p1 = *p2  ;
*p2 = temp  ;

printf("\n Two Number after swapping :%d, %d ", *p1, *p2) ;
return ( 0 );

}

Output of Program :

Output of Program in C to swap two number using pointer