Concept Flow - Built-in data types
Start
Declare variable with built-in type
Assign value
Use variable in operations
Output or store result
End
This flow shows how built-in data types are declared, assigned values, used, and then output or stored.
#include <iostream> int main() { int a = 5; float b = 3.2f; char c = 'X'; bool d = true; std::cout << a << b << c << d; return 0; }
| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Declare int a | a | undefined | |
| 2 | Assign 5 to a | a | 5 | |
| 3 | Declare float b | b | undefined | |
| 4 | Assign 3.2 to b | b | 3.2 | |
| 5 | Declare char c | c | undefined | |
| 6 | Assign 'X' to c | c | 'X' | |
| 7 | Declare bool d | d | undefined | |
| 8 | Assign true to d | d | true | |
| 9 | Output variables | a,b,c,d | 5,3.2,'X',true | 53.2X1 |
| 10 | End of program |
| Variable | Start | After Step 2 | After Step 4 | After Step 6 | After Step 8 | Final |
|---|---|---|---|---|---|---|
| a | undefined | 5 | 5 | 5 | 5 | 5 |
| b | undefined | undefined | 3.2 | 3.2 | 3.2 | 3.2 |
| c | undefined | undefined | undefined | 'X' | 'X' | 'X' |
| d | undefined | undefined | undefined | undefined | true | true |
Built-in data types in C++ include int, float, char, bool. Declare variables with type, assign values. Use 'f' suffix for float literals. Bool prints as 1 (true) or 0 (false). Variables hold undefined data before assignment.
Which built-in data type in C++ is used to store whole numbers without decimals?
int type stores whole numbers like 1, 2, -5.Which of the following is the correct way to declare a variable of type char in C++?
?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;
}flag is set to 0, which means false in boolean context.flag is false, the else block runs, printing "False".Identify the error in this C++ code snippet:
double price = 9.99;
char letter = "B";
bool isAvailable = true;letter is declared as char but assigned with double quotes, which is incorrect.You want to store a person's age, initial letter of their name, and whether they are a student. Which built-in data types should you use in C++?
int is suitable.char fits.bool is best.Pass the test and this pattern moves unknown