| CMPSC 101 - Variables Worksheet #6 | Name - |
1. In the right margin, show what output would be displayed by the following program.
#include <iostream>
using namespace std;int main()
{
int a = 3;
int b = 4;
int c = 8;
if (a < b)
cout << "a is less than b" << endl;
else
cout << "b is less than a" << endl;
cout << "b is less than c" << endl;
return 0;
}
2. What is the value (TRUE or FALSE) of the following possible
if statement control expressions where the integer variables a, b, & c
have the following values:
a = 1, b = 2 & c = 3. Write
out the word TRUE or FALSE.
|
a/ (a < b || c = = 2) b/ (a < b && (c = 2)) c/ (3 < b + a) d/ (b < 1 || a > 0 && b < 0) |
e/ (!(b > a)) f/ (b) g/ (!a) h/ (0 - c) |
3. Evaluate the following expression where a = 5 and b = 6. Write either TRUE or FALSE.
(a < b || (!b) && 6 >= b && (b < 3 || a))
4. Write an if/else statement that displays the message "finished" if the value of the variable numberOfTimes is greater than or equal to 5. Otherwise, the message "not finished" displays.