#include
//function to swap values
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
printf("\nValues of a and b within the function: %d %d",*a,*b);
}
int main()
{
int a,b;
//Accept value of a & b
printf("\nEnter value of a:");
scanf("%d",&a);
printf("\nEnter value of b:");
scanf("%d",&b);
//print values before calling swap function
printf("\nValues of a and b before calling the function: %d %d",a,b);
//Calling swap function
swap(&a,&b);
//print values after calling the swap function
printf("\nValues of a and b after calling the function: %d %d",a,b);
}
0 comments: