The “if” Control Structure, Example 2
•
#include <iostream>
•
int main()
•
{
•
int x = 6, y = 12;
•
if ( x < 5 )
•
{
•
cout << “y = “ << y << endl;
•
}
•
cout << “x = “ << x << endl;
•
return 0;
•
}
What does this program print?
Since x < 5 is false the code between the if statements braces is not executed. The next statement to be executed is cout << “x = “ << x << endl; So the program prints x = 6