C++ Nested If Examples

 

bonus = 0;

if (sales > 300000)

          {if (years_employed > 2)

                   {bonus = 1000;}

           else

                   {bonus = 500;}

          }

{cout << “bonus = “ << bonus << endl;}

 

**********************************

 

if (age > 17)

{if (registered = = 1)

cout << “you may vote” << endl;

  else

{cout << “you must register to vote” << endl;}

 

}

else

{cout << “you are too young to vote” << endl;}