Function with Multiple Parameters in C

Level 393 keystrokes

Defines a function with two parameters that returns their sum.

C code

// Two parameters, separated by commas, each with its own type
1int add(int a, int b) {
// Return the sum to the caller
2 return a + b;
3}
4
// Arguments are matched by position: a = 3, b = 4
5int result = add(3, 4);
// Print Sum: 7
6printf("Sum: %d\n", result);

Output

Sum: 7
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
  • (× 3
  • )× 3
  • "× 2
  • :× 1
  • {× 1
  • }× 1
  • \× 1
  • %× 1

More C examples at level 3

← C typing practice