We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9433006 commit 78fa4a1Copy full SHA for 78fa4a1
snippets/c/mathematical-functions/swap-numbers.md
@@ -0,0 +1,19 @@
1
+---
2
+title: Swap numbers
3
+description: Swaps two numbers without using third variable
4
+author: Emosans
5
+tags: swap,numbers
6
7
+
8
+```c
9
+#include<stdio.h>
10
+void swap(int* num1,int* num2){
11
+ *num1= *num1 + *num2;
12
+ *num2= *num1 - *num2;
13
+ *num1= *num1 - *num2;
14
+}
15
16
+// Usage:
17
+int a=3,b=4;
18
+auto swapped=swap(&a,&b); // simply use printf after this to print swapped values
19
+```
snippets/cpp/math-and-numbers/swap-numbers.md
0 commit comments