/*
  Working with if statements.  see Nyhoff P121-124
*/

#include <iostream>
#include <cmath>                // sqrt
#include <cstdlib>              // exit

/*
    if (<boolean expression>)
       {
          statements to be run if boolean expression is true.
       }

or in the form:

    if (<boolean expression>)
       {
          statements to be run if boolean expression is true.
       }
    else
       {
          statements to be run if boolean expression is false.
       }


Note that if there is only a single statement to be run, then we do not need { .. } brackets.

*/

using namespace std;

int main()
{
   double x=1;

// If with only one line if boolean is true                 Note formatting does not matter!
   if (x>=0) cout << "x is positive" << endl;

   int n=42;

// If with true/false branches with one single statement.   Note formatting does not matter!
   if (n%2==0) cout << "n=" << n << " is an even number" << endl;
          else cout << "n=" << n << " is an odd number" << endl;
   
// If with multiple statements
   if (x==0)
        {
          cout << "x=0 so we can't progress any further sorry!";
          exit(1);
        }
     else
        {
          cout << "x is not zero!";
        }
    
   return 0;
}
