0
0
Cprogramming~10 mins

Why operators are needed in C - Test Your Understanding

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

Complete 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'
A-
B/
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction - instead of addition.
2fill in blank
medium

Complete 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'
A>
B<=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than < instead of greater than.
3fill in blank
hard

Fix 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'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition + instead of multiplication.
4fill in blank
hard

Fill 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'
A>=
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using > or < which exclude boundaries.
5fill in blank
hard

Fill 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'
Aa
Bb
Cc
Davg
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable avg inside its own calculation.