Challenge - 5 Problems
C Program Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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; }
Attempts:
2 left
💡 Hint
Look carefully at the exact string printed and the newline character.
✗ Incorrect
The program prints exactly "Hello, C world!" followed by a newline, so the output is that text on one line.
❓ Predict Output
intermediate2: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; }
Attempts:
2 left
💡 Hint
x starts at 5 and then 10 is added.
✗ Incorrect
x is initialized to 5, then 10 is added, so x becomes 15.
❓ Predict Output
advanced2: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; }
Attempts:
2 left
💡 Hint
Look at how printf handles newlines.
✗ Incorrect
The greet function prints "Hi! " without newline, then main prints the rest with newline, so output is on one line with newline at end.
❓ Predict Output
advanced2: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; }
Attempts:
2 left
💡 Hint
Check each line for missing punctuation.
✗ Incorrect
The line 'int a = 10' is missing a semicolon at the end, causing a syntax error.
🧠 Conceptual
expert2: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; }
Attempts:
2 left
💡 Hint
Count all functions including main.
✗ Incorrect
There are three functions: first, second, and main.