swapping using pointers and functions
#include<stdio.h>
int swap(int *a,int *b);
int main()
{
int a=4,b=5;
swap(&a,&b);
printf(
"after swapping a=%d\n b=%d",a,b);
}
int swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
return *a,*b;
}
Comments
Post a Comment