Contact Learn C
Copy Program Share Program

Program 187:Swap two numbers using Pointers

Program 187:
 
 #include<stdio.h>
void swap(int *,int*);
main( )
{
int a,b;
printf("Enter a and b values\n");
scanf("%d%d",&a,&b);
printf ("Values before Swap\na=%d\nb=%d\n",a,b ) ;
swap(&a,&b ) ;
printf ("Values after Swap\na=%d\nb=%d\n",a,b ) ;
}
void swap( int *x, int *y )
{
int t ;
t = *x ;
*x = *y ;
*y = t ;
}


Explanation:

//Coming Soon...

Output:








 

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide