Swap Values of Two Variables with C language
#include <stdio.h>
int main()
{
int x,y,temp;
printf("value of x : ");
scanf("%d", &x);
printf("\nvalue of y : ");
scanf("%d", &y);
temp = x;
x = y;
y = temp;
printf("\nAfter swapping values \n");
printf("x : %d\n", x);
printf("y : %d", y);
return 0;
}
Output
value of x : 5
value of y : 10
After swapping values
x : 10
y : 5
0 Comments