Objects, types, and values.
Understand declarations, integer ranges, initialization, and const-qualified views.
The idea behind the syntax.
An object is a region of data storage that can hold a value. A declaration gives the compiler a type for that region, and an initializer gives it a starting value. C has integer types with different ranges, floating types for approximate real-number arithmetic, and character types used for small integer values and text bytes. A type governs which operations are meaningful and how values are represented and converted.
Do not assume an int always has one particular number of bits. The standard guarantees minimum ranges and relationships among integer types, while a target implementation chooses exact widths within those rules. When a program needs a specific width for a file format or protocol, stdint.h offers types such as uint32_t where the implementation provides them. For ordinary counts, a type such as size_t is designed to represent object sizes.
What C guarantees.
Initialization matters because an automatic local object without an initializer does not acquire a useful default value. Reading its indeterminate value can make a program invalid. An object with static storage duration is initialized differently, but relying on that distinction as a shortcut makes code harder to read. State the intended starting value when it carries meaning.
const qualifies an access path so code using that path cannot modify the object through it. It is not a promise that no other access path could change the same underlying object. A const local binding also documents intent, while an enum constant or macro may be better for a compile-time named integer in some contexts. The example uses const for a value that should not change during the calculation.
Why the detail matters.
C distinguishes an object's type from the interpretation a programmer wishes to give its bits. A signed integer type has a defined range chosen by the implementation within standard limits. Converting a value to a narrower type may change it or become implementation-defined depending on the types involved. Fixed-width integer types are useful for serialized data, but their existence and exact names depend on whether the target supplies those widths. The type choice should come from a value range and an operation, not from a habit learned on one machine.
The lifetime of an automatic object begins when its block is entered and ends when the block is left. An initializer can depend on values already computed, so reading a declaration from top to bottom reveals the state available at that point. const does not create storage by itself and does not prove global immutability through every alias. It simply limits modification through a qualified access path. That distinction becomes important once pointers and shared objects appear later in the course.
See the rule in context.
#include <stdio.h>
#include <stddef.h>
int main(void) {
const int price = 7;
size_t quantity = 4;
long total = (long)price * (long)quantity;
printf("Total: %ld\n", total);
return 0;
}price begins as 7 and is not modified. quantity has type size_t, a type suitable for counts and sizes. Both operands are converted to long before multiplication, so the expression has type long. printf uses %ld to match that type and displays Total: 28. The cast does not guarantee that every conceivable quantity fits in long; a real boundary check would be needed for large external values.
Where the rule stops.
A mismatched printf conversion specifier and argument type is not a harmless display mistake. Variadic calls do not have enough type information to repair such a mismatch automatically.
Keep this model.
Once declarations and ranges are clear, expressions become easier to reason about. The next chapter asks how C combines values, when it converts them, and why apparently simple arithmetic can be unsafe at a boundary.