Swap Values in C
Level 379 keystrokes
Swaps the values of a and b through a temporary variable temp, then prints "a=10, b=5".
C code
// Declares the two variables to swap: a is 5, b is 101int a = 5, b = 10;// Saves a (5) first, because the next line overwrites it2int temp = a;// a takes the value of b and becomes 103a = b;// b gets the saved old value of a, 54b = temp;// Prints a=10, b=5, showing that the values were swapped5printf("a=%d, b=%d\n", a, b);Output
a=10, b=5
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
=× 7;× 5,× 4"× 2%× 2(× 1)× 1\× 1