Skip to main content

Variables in C

A variable is a named container that occupies a memory location to store a value. That value can be read and changed during program execution.

Declaration and Initialization

Declaration — reserves memory for the variable:
Initialization — declaration + assigning a value:
Syntax:

Naming Conventions


Variable Classification by Data Type


Variable Classification by Scope


Format Specifiers

Used with printf() and scanf() to read/print specific types:

Example