Concept Flow - Basic data types
Start Program
Declare Variables
Assign Values
Use Variables
End Program
The program starts by declaring variables of different basic data types, assigns values to them, uses them, and then ends.
int a = 5; float b = 3.14f; char c = 'X'; printf("%d %f %c", a, b, c);
| 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.14 to b | b | 3.14 | |
| 5 | Declare char c | c | undefined | |
| 6 | Assign 'X' to c | c | 'X' | |
| 7 | Print values | a,b,c | 5, 3.14, 'X' | 5 3.140000 X |
| 8 | Program ends |
| Variable | Start | After Step 2 | After Step 4 | After Step 6 | Final |
|---|---|---|---|---|---|
| a | undefined | 5 | 5 | 5 | 5 |
| b | undefined | undefined | 3.14 | 3.14 | 3.14 |
| c | undefined | undefined | undefined | 'X' | 'X' |
Basic data types in C: - int: whole numbers (e.g., 5) - float: decimal numbers (e.g., 3.14) - char: single characters (e.g., 'X') Declare variables, assign values, then use them. Uninitialized variables hold garbage until assigned.
int type in C.float stores decimals, char stores characters, and bool stores true/false values.float followed by the variable name and value.char letter = 'A';
int number = 5;
float decimal = 3.5;
printf("%c %d %.1f", letter, number, decimal);%c prints a character, %d prints an integer, and %.1f prints a float with one decimal place.letter = 'A' prints 'A', number = 5 prints 5, and decimal = 3.5 prints 3.5 with one decimal.bool flag = 1; char letter = "B"; int count = 10;
char is the right type.bool fits perfectly.Pass the test and this pattern moves unknown