Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if both conditions are true.
C++
bool result = (a > 5) [1] (b < 10);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using bitwise AND (&) instead of logical AND (&&).
Using logical OR (||) when both conditions must be true.
✗ Incorrect
The logical AND operator && returns true only if both conditions are true.
2fill in blank
mediumComplete the code to check if either condition is true.
C++
bool result = (x == 0) [1] (y != 0);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical AND (&&) when only one condition needs to be true.
Using bitwise OR (|) instead of logical OR (||).
✗ Incorrect
The logical OR operator || returns true if at least one condition is true.
3fill in blank
hardFix the error in the condition to correctly negate the expression.
C++
if ([1]) { // do something }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using bitwise NOT (~) instead of logical NOT (!).
Not negating the flag when needed.
✗ Incorrect
The logical NOT operator ! negates the boolean value of flag.
4fill in blank
hardFill both blanks to create a condition that is true only if a is positive and b is not zero.
C++
if ((a [1] 0) [2] (b != 0)) { // code here }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical OR (||) instead of AND (&&) when both conditions must be true.
Using less than (<) instead of greater than (>) for positive check.
✗ Incorrect
The condition checks if a is greater than zero and b is not zero using logical AND &&.
5fill in blank
hardFill all three blanks to create a condition that is true if x is zero or y is positive and z is false.
C++
if ((x [1] 0) [2] (y [3] 0 && !z)) { // action }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical AND (&&) instead of OR (||) between x and y conditions.
Using less than (<) instead of greater than (>) for y check.
✗ Incorrect
The condition checks if x equals zero or (y is greater than zero and z is false).