/*
    Using break/continue statement in loops. Nyhoff 274
    
    Some times more clean code can be written using break/continue inside loops.

    The example below is somewhat contrived, since we could just change the for
    loop to (int i=0; i<7 ; i+=2) to have the same effect.
    
    What is the final sum that is printed?
*/

#include <iostream>
using namespace std;

int main()
{
   int sum=0;
   for (int i=0; i<10 ; i++)
     {
        if (i%2==0) continue;        // If even skip to end of loop
        if (sum>9)  break;           // Stop the loop if sum is above 9

        sum+=i;
        cout << "i=" << i << "  sum=" << sum << "\n";
                
        // Continue jumps here when condition true.
     }
  // Break jumps here when condition true.
  
   cout << "The final value of sum is " << sum << endl;

   return 0;
}
