Write a C-program to print swaping of two numbers without using third variable
#include <stdio.h>
int main() {
int x,y;
printf("Enter x,y values");
scanf("%d%d",&x,&y);
printf("Before Swapping x value is %d",x);
printf("\nBefore Swapping y value is %d",y);
x=x+y;
y=x-y;
x=x-y
printf("\n\nAfter Swapping x value is %d",x);
printf("\nAfter Swapping y value is %d",y);
return 0;
}
Output:
Enter x,y values10 20
Before Swapping x value is 10
Before Swapping y value is 20
After Swapping x value is 20
After Swapping y value is 10
More Programs
13 . Write a C-program to print swaping of two numbers without using third variable
14 . Write a C-program to print relation of two numbers
15 . Write a C-program to print logical operators program using &&, || ,!
16 . Write a C-program to print bitwise AND operation
17 . Write a C-program to print bitwise OR operation
18 . Write a C-program to print bitwise CAP operation
19 . Write a C-program to print bitwise NEGATION operation
20 . Write a C-program to print bitwise LEFT SHIFT operation
21 . Write a C-program to print bitwise RIGHT SHIFT operation
22 . Write a C-program to print odd or even number using ternary operator
23 . Write a C-program to print max number using ternary operator