We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c5c05c2 commit 58c0e1fCopy full SHA for 58c0e1f
swap two numbers without third variable
@@ -0,0 +1,11 @@
1
+#include<stdio.h>
2
+ int main()
3
+{
4
+int a=10, b=20;
5
+printf("Before swap a=%d b=%d",a,b);
6
+a=a+b;//a=30 (10+20)
7
+b=a-b;//b=10 (30-20)
8
+a=a-b;//a=20 (30-10)
9
+printf("\nAfter swap a=%d b=%d",a,b);
10
+return 0;
11
+}
0 commit comments