0
0
Cprogramming~20 mins

Basic data types - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Basic Data Types Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of integer and float operations
What is the output of this C code snippet?
C
#include <stdio.h>
int main() {
    int a = 5;
    float b = 2.0;
    printf("%f", a / b);
    return 0;
}
A2
B2.000000
C2.500000
D0.000000
Attempts:
2 left
💡 Hint
Remember that dividing an int by a float results in a float.
Predict Output
intermediate
2:00remaining
Size of data types
What will this program print?
C
#include <stdio.h>
int main() {
    printf("%zu", sizeof(char) + sizeof(int));
    return 0;
}
A4
B6
C8
D5
Attempts:
2 left
💡 Hint
On most systems, char is 1 byte and int is 4 bytes.
Predict Output
advanced
2:00remaining
Unsigned integer overflow behavior
What is the output of this code?
C
#include <stdio.h>
int main() {
    unsigned int x = 0;
    x = x - 1;
    printf("%u", x);
    return 0;
}
ACompilation error
B4294967295
C-1
D0
Attempts:
2 left
💡 Hint
Unsigned integers wrap around on underflow.
Predict Output
advanced
2:00remaining
Character and integer conversion
What does this program print?
C
#include <stdio.h>
int main() {
    char c = 'A';
    int i = c + 1;
    printf("%c %d", i, i);
    return 0;
}
AB 66
BA 65
CC 67
DCompilation error
Attempts:
2 left
💡 Hint
Characters are stored as numbers internally.
🧠 Conceptual
expert
2:00remaining
Behavior of signed integer overflow
What happens when a signed int variable in C overflows?
AIt causes undefined behavior according to the C standard.
BIt clamps to the maximum or minimum int value.
CIt wraps around like unsigned int, producing a defined value.
DIt triggers a runtime error automatically.
Attempts:
2 left
💡 Hint
Signed integer overflow is not defined by the C standard.