Nearby lessons
33 of 124C - sizeof Operator
sizeof Operator is one of the foundational topics in C programming. This lesson explains The sizeof Operator — Memory Sizes and Program: size of every basic type with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
The sizeof Operator — Memory Sizes
sizeof tells you exactly how many bytes a data type takes on your computer. Run it and see your own machine's sizes:
In simple words: sizeof is a weighing machine for data types — it tells you exactly how many bytes a type needs on your computer.
Program: size of every basic type
Trainer's Note: Sizes can change with the compiler and operating system. On 64-bit Linux, long is usually 8 bytes; on Windows it is 4 bytes (as shown above). That is exactly why sizeof exists — it prints the truth for your machine. char is the one type the C language fixes: it is always 1 byte.
Example02
📝 Key Takeaways
- Tokens = keywords, identifiers, constants, operators, special symbols.
- Constants never change; variables can hold different values.
- Identifier rules: start with letter/underscore, no spaces/symbols, no keywords.
- Basic data types: int, float, double, char — each with its own example program.
- Declaration = type + name; initialization = giving a value.
- sizeof tells the memory size of a type.
🧠 Test Your Knowledge
1 QuestionsProgress: 0 / 1