Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

new snippet - swap numbers #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changes
  • Loading branch information
Emosans committed Jan 4, 2025
commit bf49d9c496adf9f42df75e74c0341e784896112d
10 changes: 5 additions & 5 deletions snippets/c/mathematical-functions/swap-numbers.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ tags: swap,numbers
```c
#include<stdio.h>
void swap(int* num1,int* num2){
*num1= *num1 + *num2;
*num2= *num1 - *num2;
*num1= *num1 - *num2;
*num1= *num1 + *num2;
*num2= *num1 - *num2;
*num1= *num1 - *num2;
}

// Usage:
int a=3,b=4;
auto swapped=swap(&a,&b); // simply use printf after this to print swapped values
int a = 3,b = 4;
swap(&a,&b); // simply use printf after this to print swapped values
Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite like the comment here, i would prefer something along the lines of Swaps the values of the a and b variables

Appart from that it looks good

```

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /