2. (A) Write a program to swap two numbers without using third variable.

2. (A) Write a program to swap two numbers without using third variable. 
 Write a program to swap two numbers without using third variable.

#include<stdio.h>
int main() {
int a, b;
printf("\nEnter value for num1 & num2 : ");
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("\nAfter swapping value of a : %d", a);
printf("\nAfter swapping value of b : %d", b);
return (0);
}
2. (A) Write a program to swap two numbers without using third variable. 2. (A) Write a program to swap two numbers without using third variable. Reviewed by admin on December 22, 2019 Rating: 5

No comments:

Powered by Blogger.