Built-in data types are the basic types provided by C++ to store simple values like numbers, characters, and boolean values. Examples include int, char, float, double, and bool.
Click to reveal answer
beginner
What is the difference between int and float in C++?
int stores whole numbers without decimals, while float stores numbers with decimals (fractional parts).
Click to reveal answer
beginner
What is the size of a bool type in C++ and what values can it hold?
bool typically uses 1 byte and can hold only two values: true or false.
Click to reveal answer
beginner
Which built-in data type would you use to store a single character in C++?
You use the char type to store a single character, like 'a' or 'Z'.
Click to reveal answer
intermediate
What is the difference between float and double?
double stores floating-point numbers with double the precision of float. It uses more memory but is more accurate for decimals.
Click to reveal answer
Which C++ built-in data type is used to store true or false values?
Aint
Bbool
Cchar
Dfloat
✗ Incorrect
bool is the type designed to hold true or false values.
What type would you use to store the number 42 in C++?
Abool
Bfloat
Cchar
Dint
✗ Incorrect
The number 42 is a whole number, so int is the correct type.
Which data type can store decimal numbers with more precision?
Adouble
Bchar
Cint
Dfloat
✗ Incorrect
double stores decimal numbers with more precision than float.
What is the size of a char in C++?
A1 byte
B2 bytes
C4 bytes
D8 bytes
✗ Incorrect
char typically uses 1 byte to store a single character.
Which of these is NOT a built-in data type in C++?
Aint
Bdouble
Cstring
Dbool
✗ Incorrect
string is not a built-in data type; it is a class in the standard library.
List the main built-in data types in C++ and describe what kind of values each stores.
Think about numbers, letters, and true/false values.
You got /9 concepts.
Explain the difference between float and double in terms of precision and memory.
One stores decimals more accurately but uses more memory.
You got /5 concepts.
Practice
(1/5)
1.
Which built-in data type in C++ is used to store whole numbers without decimals?
easy
A. int
B. double
C. char
D. bool
Solution
Step 1: Understand data types for numbers
Whole numbers without decimals are stored in integer types.
Step 2: Identify the integer type in C++
The int type stores whole numbers like 1, 2, -5.
Final Answer:
int -> Option A
Quick Check:
Whole numbers = int [OK]
Hint: Whole numbers use int type in C++ [OK]
Common Mistakes:
Choosing double for whole numbers
Using char for numbers
Confusing bool with numbers
2.
Which of the following is the correct way to declare a variable of type char in C++?
?
easy
A. char letter = 65
B. char letter = "A";
C. char letter = A;
D. char letter = 'A';
Solution
Step 1: Understand char initialization
Characters must be enclosed in single quotes in C++.
Step 2: Check each option
char letter = 'A'; uses single quotes correctly. char letter = "A"; uses double quotes (string). char letter = A; misses quotes. char letter = 65; uses an int, which is allowed but not typical for char.
Final Answer:
char letter = 'A'; -> Option D
Quick Check:
char uses single quotes for characters [OK]
Hint: Use single quotes for char values [OK]
Common Mistakes:
Using double quotes for char
Missing quotes around character
Assigning int without cast
3.
What will be the output of the following C++ code?
#include <iostream>
int main() {
bool flag = 0;
if (flag) {
std::cout << "True";
} else {
std::cout << "False";
}
return 0;
}
medium
A. True
B. False
C. 0
D. 1
Solution
Step 1: Understand bool initialization
The variable flag is set to 0, which means false in boolean context.
Step 2: Check the if condition
Since flag is false, the else block runs, printing "False".