0
0
Cprogramming~20 mins

Writing first C program - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
C Programming Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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;
}
ACompilation error
BHello, C World!
CHello, C World!\n
Dhello, c world!
Attempts:
2 left
💡 Hint
Remember that printf prints the string exactly, and \n means new line.
Predict Output
intermediate
2: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;
}
ASum is 8
BSum is 53
CCompilation error
DSum is %d
Attempts:
2 left
💡 Hint
The %d in printf is replaced by the integer value of a + b.
Predict Output
advanced
2: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;
}
ANo error, prints 'Missing semicolon'
BRuntime error
CSyntax error: expected ';' before 'return'
DLinker error
Attempts:
2 left
💡 Hint
Check if all statements end with a semicolon.
Predict Output
advanced
2: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;
}
A1 2 3
B123
C1 2 3\n
DCompilation error
Attempts:
2 left
💡 Hint
The loop prints numbers 1 to 3 separated by spaces.
🧠 Conceptual
expert
2: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;
}
A2
B5
C4
D3
Attempts:
2 left
💡 Hint
Count how many numbers from 0 to 4 are even.