Skip to content

Commit 78fa4a1

Browse files
committed
snippet- changed to C
1 parent 9433006 commit 78fa4a1

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)