Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a number is positive.
C
if (num [1] 0) { printf("Positive\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will check for negative numbers.
Using '==' checks for equality, not positivity.
✗ Incorrect
The condition num > 0 checks if the number is positive.
2fill in blank
mediumComplete the code to print "Even" if the number is even.
C
if (num % 2 [1] 0) { printf("Even\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' will check for odd numbers instead.
Using '>' or '<' does not correctly check for evenness.
✗ Incorrect
The condition num % 2 == 0 checks if the number is even.
3fill in blank
hardFix the error in the if statement to check if a number is negative.
C
if (num [1] 0) { printf("Negative\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' checks for positive numbers instead.
Using '==' checks for zero, not negativity.
✗ Incorrect
The condition num < 0 correctly checks if the number is negative.
4fill in blank
hardFill both blanks to complete the if-else statement that prints if a number is positive or not.
C
if (num [1] 0) { printf("Positive\n"); } else { printf("[2]\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' in the first blank reverses the logic.
Printing 'Zero' instead of 'Negative' changes the meaning.
✗ Incorrect
The condition num > 0 checks positivity, else it prints "Negative".
5fill in blank
hardFill all three blanks to complete the if-else if-else statement that checks if a number is positive, zero, or negative.
C
if (num [1] 0) { printf("Positive\n"); } else if (num [2] 0) { printf("Zero\n"); } else { printf("[3]\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up comparison operators.
Printing wrong labels for conditions.
✗ Incorrect
The first condition checks if num > 0, second if num == 0, else prints "Negative".