Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to increase the value of count by 1 using the increment operator.
C
int count = 5; count[1]; printf("%d", count);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the decrement operator
-- instead of increment.Using
+= without specifying the value.✗ Incorrect
The increment operator
++ increases the value of a variable by 1.2fill in blank
mediumComplete the code to decrease the value of num by 1 using the decrement operator.
C
int num = 10; [1]num; printf("%d", num);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the increment operator
++ instead of decrement.Placing the operator after the variable when the problem expects before.
✗ Incorrect
The decrement operator
-- decreases the value of a variable by 1. Placing it before the variable decreases the value before use.3fill in blank
hardFix the error in the code to correctly increment value by 1.
C
int value = 7; value [1]; printf("%d", value);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing just
++ without the variable.Using
value+1 which does not change the variable.✗ Incorrect
Using
value++ increments the value after its current use. It is a correct way to increase by 1.4fill in blank
hardFill both blanks to create a loop that decreases i from 5 to 1.
C
for(int i = 5; i [1] 0; i[2]) { printf("%d ", i); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
< instead of > in the condition.Using
++ instead of -- in the update.✗ Incorrect
The loop runs while
i is greater than 0 and decreases i by 1 each time using --.5fill in blank
hardFill all three blanks to create a loop that prints numbers from 1 to 5 using increment.
C
for(int num = [1]; num [2] 5; num[3]) { printf("%d ", num); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Starting from 0 instead of 1.
Using
< instead of <= in the condition.Using decrement operator instead of increment.
✗ Incorrect
The loop starts at 1, runs while
num is less than or equal to 5, and increments num by 1 each time.