Use a return statement in the middle of a loop. - C++ Function

C++ examples for Function:Function Return

Description

Use a return statement in the middle of a loop.

Demo Code

#include <iostream> 
using namespace std ; 

int main(){/*from  w  w  w.  ja  va2 s  .  c  o  m*/

    int i = 10; 
    while (true ) { 
       if (i == 0) { 
          return 0; 
       } 
       cout << i << "\n"; 
       i --; 
    } 
} 

Result


Related Tutorials