C - Lab4 - Eng - Ruqaih Salman Final 2022
C - Lab4 - Eng - Ruqaih Salman Final 2022
Lab4 Exercises
• jf ojluc. JJJUII
d. The expression in the if statement: always evaluates to true.
if (score = 30)
grade = 'A';
.'ch> = 'Z J 'ch <’A 13I false J) ('ch> = 'A' && ch <= 'Z) :j^li A
e. The expression: (ch >= 'A' && ch <= ’Z’) evaluates to false if either ch < ’A' or ch >= ’Z’.
f. Suppose the input is 5. The output of the code is: Num is zero
Num is zero .5
a. 5 + 6 == 3 + 7
b. 2 * 6 - 4 >= 9 - 1
c. ’U’ >= r
d. 'A' <= ’a'
t 6.28/3 <3-1.2
•false true Aulllll dijl£ I3I lx
3. Suppose that x, y, and z are int variables, and x = 10, y = 15, and z = 20. Determine whether the following
expressions evaluate to true or false.
(
oiCuis 1311» .z = 20 j y = 15 j x = 10 ‘ int ^j'z j y j xJJS'
.false -true
a. !(x > 10)
b. x <= 5 || y < 15
C. (x != 5) && (y != z)
d. x >= z || (x + y >= z)
e. (x <= y - 2) && (y >= z) || (z - 2 != 20)
4. Suppose that x, y, z, and w are int variables, and x = 3, y = 4, z = 7, and w = 1. What is the output of the following
statements?
oijLxli gli u ,w = 1 jz = 7jy = 4jx = 3 ub ‘ int ^WjZjyjXcJ
a. cout « ”x == y: ’’ « (x == y) « endl;
b. cout << "x != z: " << (x != z) << endl;
C. cout << "y == z - 3: ” << (y == z - 3) << endl;
d. cout << "!(z > w): ’’ << !(z > w) << endl;
e. cout << ”x + y < z: ” << (x + y < z) << endl;
d. :
e. <>