Simvik

Return true or false

Write a function that answers a yes-or-no question. An easy embedded C problem (Functions), run and graded in the browser.

easy · Functions · bool

The type bool holds true or false. Functions that answer a question return it.

Return true if v lies between lo and hi, with both ends included.

Starter code

bool in_range(int v, int lo, int hi) {
  return false;
}

Example tests

Inside

printf("%d\n", in_range(5, 1, 10));

Expected output:

1

Outside

printf("%d\n", in_range(11, 1, 10));

Expected output:

0

Learn it first

  • Functions · Splitting a program into named pieces, passing values in and getting results back.

More Functions problems