0
0
Cprogramming~20 mins

Structure of a C program - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
C Program Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a simple C program with main function
What is the output of this C program when compiled and run?
C
#include <stdio.h>

int main() {
    printf("Hello, C world!\n");
    return 0;
}
Ahello, c world!
BHello, C world!\n
CHello, C world!
DCompilation error
Attempts:
2 left
💡 Hint
Look carefully at the exact string printed and the newline character.
Predict Output
intermediate
2:00remaining
Value of variable after execution
What is the value of variable x after running this program?
C
#include <stdio.h>

int main() {
    int x = 5;
    x = x + 10;
    return 0;
}
A5
B10
CCompilation error
D15
Attempts:
2 left
💡 Hint
x starts at 5 and then 10 is added.
Predict Output
advanced
2:00remaining
Output of a program with multiple functions
What is the output of this C program?
C
#include <stdio.h>

void greet() {
    printf("Hi! ");
}

int main() {
    greet();
    printf("Welcome to C programming.\n");
    return 0;
}
AHi! Welcome to C programming.\n
BHi! Welcome to C programming.
C.gnimmargorp C ot emocleW !iH
Di! Welcome to C programming.
ECompilation error
Attempts:
2 left
💡 Hint
Look at how printf handles newlines.
Predict Output
advanced
2:00remaining
What error does this program produce?
What error will this C program produce when compiled?
C
#include <stdio.h>

int main() {
    int a = 10
    printf("Value: %d\n", a);
    return 0;
}
ASyntax error: missing semicolon
BNo error, prints 'Value: 10'
CRuntime error: undefined variable
DLinker error: missing main
Attempts:
2 left
💡 Hint
Check each line for missing punctuation.
🧠 Conceptual
expert
2:00remaining
Number of functions in this C program
How many functions are defined in this C program?
C
#include <stdio.h>

void first() {
    printf("First\n");
}

void second() {
    printf("Second\n");
}

int main() {
    first();
    second();
    return 0;
}
A3
B2
C4
D1
Attempts:
2 left
💡 Hint
Count all functions including main.