/*
  Working with if statements.  see Nyhoff P266-269
  
  Beware interpretation of nested if's!
  
  Whitespace does not matter for the compiler, hence it sees the two
  versions of the code as exactly the same. However we would interprete
  the else clause of belonging to either the first or the last if.

  Which choice does the compiler make?

*/

#include <iostream>
using namespace std;

int main()
{
   int a=3;
   int b=10;

   cout << "Version 1 of the the code. Unclear semantics" << endl;
   if (a>10)
      if (b<3) cout << "a is larger than 10 and b smaller than 3" << endl;
   else
               cout << "a is smaller than 10" << endl;


   cout << "Version 2 of the the code. Unclear semantics" << endl;
   if (a>10)
      if (b<3) cout << "a is larger than 10 and b smaller than 3" << endl;
      else     cout << "b is larger than 3" << endl;

 
   cout << "Version 3 of the the code. Clear semantics" << endl;
   if (a>10)
     {
      if (b<3) cout << "a is larger than 10 and b smaller than 3" << endl;
   else
               cout << "a is smaller than 10" << endl;
     }

   cout << "Version 4 of the the code. Clear semantics" << endl;
   if (a>10)
     {
      if (b<3) cout << "a is larger than 10 and b smaller than 3" << endl;
     }
      else     cout << "b is larger than 3" << endl;

 

   return 0;
}
