Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a number is positive.
C
if ([1] > 0) { printf("Positive number\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name not declared or used in the code.
✗ Incorrect
The variable x is used to check if it is greater than zero.
2fill in blank
mediumComplete the code to print "Even" if the number is divisible by 2.
C
if ([1] % 2 == 0) { printf("Even\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable not declared or used in the code snippet.
✗ Incorrect
The variable num is used to check divisibility by 2.
3fill in blank
hardFix the error in the condition 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 == only checks if age is exactly 18, not older.
✗ Incorrect
The operator >= 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 < or > excludes boundary values.
✗ Incorrect
The number must be greater than or equal to 10 and less than or equal to 20.
5fill in blank
hardFill all three blanks to print "Teenager" if age is between 13 and 19 inclusive.
C
if (age [1] 13 && age [2] 19 && age [3] 20) { printf("Teenager\n"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators that exclude boundary ages.
✗ Incorrect
The condition checks if age is at least 13, at most 19, and less than 20 (which is redundant but part of the exercise).