Concept Flow - Storage size overview
Declare variable
Allocate memory based on type
Check size with sizeof()
Use size for operations or info
End
This flow shows how a variable's storage size is determined by its type and checked using sizeof() in C.
int a; char b; float c; printf("Size of a: %zu\n", sizeof(a)); printf("Size of b: %zu\n", sizeof(b)); printf("Size of c: %zu\n", sizeof(c));
| Step | Action | Variable/Type | sizeof() Result (bytes) | Output |
|---|---|---|---|---|
| 1 | Declare variable | int a | - | - |
| 2 | Declare variable | char b | - | - |
| 3 | Declare variable | float c | - | - |
| 4 | Evaluate sizeof(a) | int a | 4 | Size of a: 4 |
| 5 | Evaluate sizeof(b) | char b | 1 | Size of b: 1 |
| 6 | Evaluate sizeof(c) | float c | 4 | Size of c: 4 |
| 7 | End | - | - | - |
| Variable | Start | After sizeof() |
|---|---|---|
| a (int) | declared | size = 4 bytes |
| b (char) | declared | size = 1 byte |
| c (float) | declared | size = 4 bytes |
Storage size overview in C: - Use sizeof(type_or_variable) to get size in bytes. - char is always 1 byte. - int and float sizes depend on system (commonly 4 bytes). - Sizes help understand memory use and data limits. - sizeof returns size_t, use %zu to print. - Sizes can vary by platform.