Skip to main content

13.4) Functions That Return A Value


int smallest_of(int first, int second)
{
  int smallest = first;
  if (second < first) {
    smallest = second;
  }
  return smallest;
}
  • Multiple return statements are allowed, but arguably it is clearer to have only one, at the end of the function definition
  • The value following return should match the declared return type at the start of the definition
  • The caller is free to ignore the returned value (although it is normally not useful to do so)