C Basics
Swap Two Numbers
Swap two integers without using a third variable.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Swap two integers without using a third variable.
#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;
printf("a = %d, b = %d\n", a, b);
return 0;
}
10 20
a = 20, b = 10