Challenge - 5 Problems
C Programming Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this C program?
Look at the code below. What will it print when run?
C
#include <stdio.h> int main() { printf("Hello, C World!\n"); return 0; }
Attempts:
2 left
💡 Hint
Remember that printf prints the string exactly, and \n means new line.
✗ Incorrect
The program prints the string inside printf exactly, including the new line. So it outputs 'Hello, C World!' followed by a new line.
❓ Predict Output
intermediate2:00remaining
What is the output of this C program with variables?
What will this program print when run?
C
#include <stdio.h> int main() { int a = 5; int b = 3; printf("Sum is %d\n", a + b); return 0; }
Attempts:
2 left
💡 Hint
The %d in printf is replaced by the integer value of a + b.
✗ Incorrect
The program adds 5 and 3 to get 8, then prints 'Sum is 8' followed by a new line.
❓ Predict Output
advanced2:00remaining
What error does this C program produce?
What error will this program cause when compiled?
C
#include <stdio.h> int main() { printf("Missing semicolon") return 0; }
Attempts:
2 left
💡 Hint
Check if all statements end with a semicolon.
✗ Incorrect
The printf statement is missing a semicolon at the end, causing a syntax error during compilation.
❓ Predict Output
advanced2:00remaining
What is the output of this C program with a loop?
What will this program print when run?
C
#include <stdio.h> int main() { for (int i = 1; i <= 3; i++) { printf("%d ", i); } return 0; }
Attempts:
2 left
💡 Hint
The loop prints numbers 1 to 3 separated by spaces.
✗ Incorrect
The loop prints '1 ', then '2 ', then '3 ', all on the same line with spaces.
🧠 Conceptual
expert2:00remaining
How many items are printed by this C program?
How many times does the printf statement run and print a number?
C
#include <stdio.h> int main() { int count = 0; for (int i = 0; i < 5; i++) { if (i % 2 == 0) { printf("%d ", i); count++; } } printf("\nCount: %d", count); return 0; }
Attempts:
2 left
💡 Hint
Count how many numbers from 0 to 4 are even.
✗ Incorrect
The loop prints numbers 0, 2, and 4 because they are even. So printf runs 3 times.