Help[return 0;]

If im going to make my do-while loop program, does the "return 0;" affects the process of do-while loop?
Last edited on
Yes, return 0; means return no errors and be done with the program.
What do you mean?
1
2
3
4
5
6
7
8
int main() {
  do
  {
    // code
  } while ( condition );

  return 0;
}

No effect; the return will be evaluated only after loop has completed.

1
2
3
4
5
6
7
8
9
int main() {
  do
  {
    // code
    if ( conditionB ) return 42;
    // code
  } while ( condition );
  return 0;
}

Clear effect: the program ends before the end of the loop if the conditionB is true.
^Thanks.
Topic archived. No new replies allowed.