swaping value by using pointers in c

 #include<stdio.h>

int swap ( int *a, int *b);

int main()

{

   int x = 3, y = 4;

   printf("The value of x and y before swap is %d and %d\n", x, y);

   swap(&x,&y);//will work due to call by reference

   printf("The value of x and y after swap is %d and %d\n", x, y);

return 0;

}

int swap ( int *a, int *b){

int temp;

temp = *a;

*a = *b;

*b = temp;

}

Comments

Popular posts from this blog

create a num table in a new file in c

write a programme to compare time stamp in c

write a struct programme to keep bank details in c