Simple Function in C

Level 363 keystrokes

Defines a function that returns the square of a number and calls it.

C code

// Return type int, name square, one int parameter n
1int square(int n) {
// return ends the function and hands n * n back to the caller
2 return n * n;
3}
4
// square(5) is evaluated first and returns 25, which printf prints
5printf("%d\n", square(5));

Output

25
Practice typing this code

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.

  • (× 3
  • )× 3
  • ;× 2
  • "× 2
  • ,× 1
  • {× 1
  • }× 1
  • *× 1
  • \× 1
  • %× 1

More C examples at level 3

← C typing practice