0
0
Cprogramming~10 mins

Increment and decrement operators - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A+=
B--
C++
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using the decrement operator -- instead of increment.
Using += without specifying the value.
2fill in blank
medium

Complete 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'
A--
Bnum++
Attempts:
3 left
💡 Hint
Common Mistakes
Using the increment operator ++ instead of decrement.
Placing the operator after the variable when the problem expects before.
3fill in blank
hard

Fix 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'
A++value
B++
Cvalue+1
Dvalue++
Attempts:
3 left
💡 Hint
Common Mistakes
Writing just ++ without the variable.
Using value+1 which does not change the variable.
4fill in blank
hard

Fill 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'
A>
B<
C--
D++
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > in the condition.
Using ++ instead of -- in the update.
5fill in blank
hard

Fill 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'
A0
B<=
C++
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Starting from 0 instead of 1.
Using < instead of <= in the condition.
Using decrement operator instead of increment.