Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add two numbers and store the result.
C
int a = 5, b = 3; int sum = a [1] b;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction
- instead of addition.✗ Incorrect
The plus operator + adds two numbers together.
2fill in blank
mediumComplete the code to check if a number is greater than 10.
C
int num = 15; if (num [1] 10) { // do something }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than
< instead of greater than.✗ Incorrect
The greater than operator > checks if the left value is bigger than the right.
3fill in blank
hardFix the error in the code to multiply two numbers.
C
int x = 4, y = 6; int product = x [1] y;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition
+ instead of multiplication.✗ Incorrect
The multiplication operator * multiplies two numbers.
4fill in blank
hardFill both blanks to create a condition that checks if a number is between 5 and 10 (inclusive).
C
int val = 7; if (val [1] 5 && val [2] 10) { // inside range }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
> or < which exclude boundaries.✗ Incorrect
Use >= to check if value is at least 5, and <= to check if it is at most 10.
5fill in blank
hardFill all three blanks to calculate the average of three numbers.
C
int a = 4, b = 8, c = 12; float avg = ([1] + [2] + [3]) / 3.0;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable
avg inside its own calculation.✗ Incorrect
The average is the sum of a, b, and c divided by 3.