Skip to content

Commit 9dc77c2

Browse files
Merge pull request #322 from sajjushaik/patch-1
Swapping numbers
2 parents be74ae2 + c54f38c commit 9dc77c2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Swapnumbers

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<stdio.h>
2+
3+
int main()
4+
5+
{
6+
7+
int a=10, b=20;
8+
9+
printf("Before swap a=%d b=%d",a,b);
10+
11+
a=a+b;//a=30 (10+20)
12+
13+
b=a-b;//b=10 (30-20)
14+
15+
a=a-b;//a=20 (30-10)
16+
17+
printf("\nAfter swap a=%d b=%d",a,b);
18+
19+
return 0;
20+
21+
}

0 commit comments

Comments
 (0)