0
0
Cprogramming~20 mins

Improving code readability - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Readability Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of nested if-else with clear indentation

What is the output of this C code snippet?

C
#include <stdio.h>

int main() {
    int x = 5;
    if (x > 3) {
        if (x < 10) {
            printf("Inside range\n");
        } else {
            printf("Too large\n");
        }
    } else {
        printf("Too small\n");
    }
    return 0;
}
AInside range
BToo large
CToo small
DNo output
Attempts:
2 left
💡 Hint

Check the conditions carefully and follow the indentation to see which block runs.

🧠 Conceptual
intermediate
1:30remaining
Best practice for variable naming

Which variable name is the most readable and follows good naming conventions in C?

Aint numberOfStudents;
Bint x;
Cint n;
Dint a1;
Attempts:
2 left
💡 Hint

Think about names that clearly describe what the variable holds.

🔧 Debug
advanced
2:00remaining
Identify the readability issue in this code

What is the main readability problem in this C code snippet?

C
int main(){int a=10;int b=20;if(a>b){printf("A is bigger\n");}else{printf("B is bigger\n");}return 0;}
AMissing semicolons
BIncorrect use of printf
CLack of spaces and indentation makes it hard to read
DVariables are not declared
Attempts:
2 left
💡 Hint

Look at how the code is spaced and arranged.

📝 Syntax
advanced
1:30remaining
Which option causes a syntax error?

Which of the following C code snippets will cause a syntax error?

Aif (x > 0) printf("Positive\n");
Bif x > 0 { printf("Positive\n"); }
C
if (x &gt; 0)
    printf("Positive\n");
Dif (x > 0) { printf("Positive\n"); }
Attempts:
2 left
💡 Hint

Remember the syntax rules for if statements in C.

🚀 Application
expert
2:00remaining
How many items are printed by this loop?

Consider this C code. How many lines will it print?

C
#include <stdio.h>

int main() {
    for (int i = 0; i < 10; i++) {
        if (i % 2 == 0) {
            printf("%d\n", i);
        }
    }
    return 0;
}
A0
B10
C9
D5
Attempts:
2 left
💡 Hint

Count how many numbers from 0 to 9 are even.