Variables in C
A variable in C is a named memory slot with a fixed type: int score = 0; binds the name score to integer storage. The type never changes afterward — assigning incompatible data is a compile error or an implicit conversion, never a dynamic retyping like Python.
Declaration and initialization are distinct ideas with real consequences. int x; inside a function leaves indeterminate garbage (reading it is undefined behavior, not zero), while int x = 5; starts life known. Initializing immediately is the habit that prevents a whole class of bugs.
Declaration fixes the type
int score; means score is always an int within its scope — C never retypes a variable behind your back.
Uninitialized means garbage
Local built-ins without initializers hold whatever bits were there — reading them is undefined behavior, not a clean zero.
Initialize immediately
int score = 0; starts known. There is no braced-init safety net like C++ — vigilance plus -Wall is the protection.
Definition vs declaration
int x = 5; at file scope defines (allocates storage once); extern int x; elsewhere merely declares it — exactly one definition per program.
#include <stdio.h> int main(void) { int score = 0; score = 42; printf("score=%d\n", score); return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C yourself — building beats watching.