write a C function to swap two number using pointer
Answers
Answered by
1
hey user here is your answer:
hope it helps you!! Mark me as the brainliest
hope it helps you!! Mark me as the brainliest
Attachments:
Answered by
0
Answer:
The program is given below :
Explanation:
#include<stdio.h>
int main()
{
int *a,*b,x,y;
printf("Enter the two number (X & Y) to swap: ");
scanf("%d%d",&x,&y); //Input two numbers
a=&x; //Store X's reference in a
b=&y; //Store Y's reference in b
printf("\nBefore swapping X = %d & Y = %d",x,y); //Print values of X and Y before swapping
//Swapping using pointers & XOR operator
*a=*a^*b;
*b=*a^*b;
*a=*a^*b;
printf("\nAfter swapping X = %d & Y = %d",x,y); //Print values of X and Y after swapping
return 0;
}
Similar questions