0
0
Cprogramming~10 mins

Improving code readability - Interactive Code Practice

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

Complete the code to declare a variable with a clear name.

C
int [1] = 10;
Drag options to blanks, or click blank then click option'
Acount
Bx
Ca
Dtmp
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague or single-letter names that don't explain the variable's purpose.
2fill in blank
medium

Complete the code to add a comment explaining the purpose of the function.

C
/* [1] */
void printMessage() {
    printf("Hello!\n");
}
Drag options to blanks, or click blank then click option'
AVariable declaration
Bint main function
CThis function prints a greeting message
DLoop through array
Attempts:
3 left
💡 Hint
Common Mistakes
Writing unclear or unrelated comments that confuse readers.
3fill in blank
hard

Fix the error in the code by choosing the best variable name for readability.

C
int [1] = 5;
printf("Value: %d\n", [1]);
Drag options to blanks, or click blank then click option'
Avalue
Bn
Ci
Dtemp
Attempts:
3 left
💡 Hint
Common Mistakes
Using single-letter or vague names that don't explain the variable's role.
4fill in blank
hard

Fill both blanks to create a clear and readable for-loop.

C
for (int [1] = 0; [1] [2] 10; [1]++) {
    printf("%d\n", [1]);
}
Drag options to blanks, or click blank then click option'
Aindex
B<
C>
Di
Attempts:
3 left
💡 Hint
Common Mistakes
Using unclear variable names or wrong comparison operators that confuse the loop's purpose.
5fill in blank
hard

Fill all three blanks to write a readable if-statement checking if a number is positive.

C
if ([1] [2] 0) {
    printf("[3] is positive\n");
}
Drag options to blanks, or click blank then click option'
Anum
B>
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names or wrong operators that make the condition unclear.