Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the number is positive.
C
if (num [1] 0) { printf("Positive number\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 age is at least 18.
C
if (age [1] 18) { printf("Adult\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' checks for younger ages.
Using '==' only checks if age is exactly 18.
✗ Incorrect
The condition age >= 18 checks if age is 18 or older.
4fill in blank
hardFill both blanks to check if a number is between 10 and 20 (inclusive).
C
if (num [1] 10 && num [2] 20) { printf("In range\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '<=' excludes 20 from the range.
Using '>' instead of '>=' excludes 10 from the range.
✗ Incorrect
The condition checks if num >= 10 and num <= 20, meaning num is between 10 and 20 inclusive.
5fill in blank
hardFill all three blanks to print "Valid" if score is above 50 and below 100.
C
if (score [1] 50 && score [2] 100) { printf("[3]\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' or '<=' changes the range to include 50 or 100.
Printing wrong message or missing quotes.
✗ Incorrect
The condition checks if score > 50 and score < 100. If true, it prints "Valid".