Swapping of two numbers without using third variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Swapping of two numbers without using third variable

#include<stdio.h> int main() { int a,b; printf("Enter two numbers"); scanf("%d%d",&a,&b); printf("Before swapping numbers are a=%d,b=%d",a,b); a=a+b; b=a-b; a=a-b; printf("After swapping numbers are a=%d,b=%d",a,b); return 0; }

2nd Nov 2020, 3:17 AM
Shaik Imam
Shaik Imam - avatar
2 Answers
+ 9
So what is your question ??
2nd Nov 2020, 3:29 AM
Arsenic
Arsenic - avatar
- 1
Yes
2nd Nov 2020, 3:30 AM
Shaik Imam
Shaik Imam - avatar