The “if” Control Structure, Example 2
•
#include <iostream>
•
int main()
•
{
•
int x = 6, y = 12;
•
if ( x < 5 || y != 15)
•
{
•
cout << “y = “ << y << endl;
•
}
•
cout << “x = “ << y << endl;
•
return 0;
•
}
What does this program print?
x < 5 is false
y != 15 is true
false || true returns true
Since the if condition is true the code between the braces is executed and y = 12 is printed, then x = 6 is printed