Simvik

Return a value

Make a function hand back a number. An easy embedded C problem (First steps in C), run and graded in the browser.

easy · First steps in C · functions · return

A function is a named piece of code that produces a result. The word before its name says what kind of result: int means a whole number.

Make answer return the number 42.

Starter code

int answer(void) {
  // Replace the 0 with the value this function should hand back.
  return 0;
}

Example tests

Returns 42

printf("%d\n", answer());

Expected output:

42

Learn it first

More First steps in C problems