C Variable Values

C Variable Values (Beginner → Advanced)
In C language, a variable value is the data stored inside a variable at a given time.
Understanding how values are assigned, updated, stored in memory, and accessed is essential for logic building, debugging, and interviews.
What is a Variable Value?
A variable value is the current data held by a variable.
a→ variable name10→ variable value
Assigning Values to Variables
At Declaration
After Declaration
- Both are valid
Changing (Updating) Variable Values
It can change during program execution.
- C variables are mutable by default
Variable Values in Expressions
- Variable values are used in calculations
Variable Values with Different Data Types
Integer
Floating-point
Character
- Each data type stores values differently in memory
Default (Garbage) Values
Local Variables (Uninitialized)
- Value is undefined
Global & Static Variables
- Automatically initialized to 0
Variable Values and Memory (Conceptual View)
Memory (example):
- Variable value is stored at a memory address
Variable Values via Pointers
- Pointer allows indirect access to variable value
Copying Variable Values (Call by Value)
aremains 10bbecomes 20
Modifying Values Using Functions
Call by Value (No Change)
Call by Reference (Change Original)
Variable Values and Scope
- Inner scope variable hides outer one
Constants vs Variable Values
- Variable values can change
- Constant values cannot
Common Mistakes
- Using uninitialized variables
- Assuming default value for local variables
- Confusing variable name with value
- Accidental overwrite of values
- Using wrong format specifier
Interview Questions (Must Prepare)
What is a variable value?
What is garbage value?
Difference between local and global variable values?
How values are passed to functions?
Can variable value change during execution?
How pointers access variable values?
Summary
- Variable value = data stored in variable
- Values can be assigned, updated, copied
- Local variables have no default value
- Global/static variables default to 0
- Pointers allow indirect access to values
- Fundamental for all C programs & interviews
