basics · beginner · ~15 min
Write and return from your first C function.
Write your first C function: take two integers and return their sum.
Implement int add(int a, int b) that returns a + b. No main — the grader calls your function.
Two ints a and b.
Returns their sum, as an int.
add(2, 3) -> 5
add(-4, 1) -> -3
add(0, 0) -> 0
Two ints a and b.
Their sum, as an int.
int add(int a, int b) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.