Simvik

Add two numbers

Use the inputs a function receives. An easy embedded C problem (First steps in C), run and graded in the browser.

easy · First steps in C · functions · parameters

The names in the parentheses are the function's parameters. They hold the values the caller passed in.

Return the sum of a and b.

Starter code

int add(int a, int b) {
  // a and b hold the two numbers to add.
  return 0;
}

Example tests

Two positive numbers

printf("%d\n", add(2, 3));

Expected output:

5

A negative number

printf("%d\n", add(-4, 10));

Expected output:

6

Learn it first

More First steps in C problems