Simvik

Average of three

Add three values and divide. An easy embedded C problem (Variables and operators), run and graded in the browser.

easy · Variables and operators · arithmetic · division

Return the average of a, b and c.

All the values are whole numbers, so the division throws away any fraction. The average of 1, 2 and 2 is 1.

Starter code

int average3(int a, int b, int c) {
  return 0;
}

Example tests

An exact average

printf("%d\n", average3(3, 6, 9));

Expected output:

6

The fraction is dropped

printf("%d\n", average3(1, 2, 2));

Expected output:

1

Learn it first

More Variables and operators problems