0
0
Cprogramming~10 mins

Relational operators in C - Interactive Code Practice

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

Complete the code to compare if a is greater than b.

C
if (a [1] b) {
    printf("a is greater than b\n");
}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>'
Using '==' which checks equality, not greater than
2fill in blank
medium

Complete the code to check if x is not equal to y.

C
if (x [1] y) {
    printf("x and y are different\n");
}
Drag options to blanks, or click blank then click option'
A!=
B==
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which checks equality, not difference
Using '>=' or '<=' which are relational but not for inequality
3fill in blank
hard

Fix the error in the condition to check if num is less than or equal to 100.

C
if (num [1] 100) {
    printf("num is 100 or less\n");
}
Drag options to blanks, or click blank then click option'
A==
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which excludes 100
Using '==' which only checks equality
4fill in blank
hard

Fill both blanks to create a condition that checks if value is between 10 and 20 inclusive.

C
if (value [1] 10 && value [2] 20) {
    printf("value is between 10 and 20\n");
}
Drag options to blanks, or click blank then click option'
A>=
B<
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '<=' excludes 20
Using '>' instead of '>=' excludes 10
5fill in blank
hard

Fill all three blanks to create a condition that checks if score is greater than 50 and less than 100.

C
if (score [1] 50 && score [2] 100 && score [3] 75) {
    printf("score is between 51 and 99 and greater than 75\n");
}
Drag options to blanks, or click blank then click option'
A>=
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' instead of '>' includes 50 which is not desired
Using '<=' instead of '<' includes 100 which is not desired
Using '<' instead of '>' for the last condition