If… else…, example 3
•
int foo = 10, bar = 15;
•
if ( (foo < bar) && ((bar % 2) == 0) )
•
{
•
foo = 2*bar;
•
}
•
else
•
{
•
bar = 2*foo;
•
}
•
cout << foo << “, ” << bar << endl;
10,30
After today’s class you will have seen all the elements needed to write this program. Basic mathematical operators, the “if” control structure, input and output, the sqrt() function.