What is a variable in C? Learn int, double, and char with clear diagrams.
int num = 5; in memory (32 bits)int num = 5;
double pi = 3.14;
int num; // Declaration: reserve memory for the variable num = 5; // Assignment: store a value ( = is "assign", NOT equality!)
= is not the equals sign; it is assignment. It stores the right-hand value into the variable on the left.x = 23; → "What is x??"x = y; copies the value of y into x (y itself does not change).| Name | Type | Value |
|---|
Check your understanding of this lesson!
The int type stores integers. For decimals, use float or double; for strings, use a char array.
Variable names must start with a letter or underscore. Names starting with a digit, or reserved words like int, are not allowed.
double is double-precision floating point (~15 digits), while float is single-precision (~7 digits). double is typically preferred.