- Given the following code, what is displayed?
int x = 3, y = 5;
cout << "x < y: " << (x < y) << endl;
cout << "x + 2 < y: " << (x + 2 < y) << endl;
cout << "x != y: " << (x != y) << endl;
cout << "x + 3 >= y: " << (x + 3 >= y) << endl;
cout << "y == x: " << (y == x) << endl;
cout << "y == x+2: " << (y == x+2) << endl;
cout << "y = x + 3: " << (y = x + 3) << endl;
- Given the following code, what is displayed?
string prevState, homeState;
prevState = "Maryland";
homeState = "Tennessee";
cout << "prevState == homeState: " << (prevState == homeState) << endl;
cout << "prevState > homeState: " << (prevState > homeState) << endl;
cout << "homeState == \"Tennessee\": " << (homeState == "Tennessee") << endl;
cout << "homeState < \"tennessee\": " << (homeState < "tennessee") << endl;
- Given the following code, what is displayed?
int age = 20;
float temperature = 102.0;
bool isSenior = false, hasFever = false;
isSenior = (age >= 55);
hasFever = (temperature > 98.6);
cout << "isSenior && hasFever: " << (isSenior && hasFever) << endl;
cout << "isSenior || hasFever: " << (isSenior || hasFever) << endl;
cout << "! isSenior: " << (! isSenior) << endl;
cout << "! hasFever: " << (! hasFever) << endl;
- Write an expression for each of the following:
- taxRate is over 25% and income is less than $20,000
- temperature is less than or equal to 75 degrees or humidity is less than 70%
- age is over 21 and less than 60
- age is 21 or 22
- Given the following code, what is displayed?
int airQuality = 35;
cout << "50 < airQuality < 80: " << (50 < airQuality < 80) << endl;
- Given the variable number (which is an int) write code to display a one word description of "Positive", "Negative" or "Zero" based on number's value.