C Variable Values

C Tutorial

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 name

  • 10 → 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):

Address: 1000 Value: 10
  •  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)


 

  • a remains 10
  • b becomes 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)

  1. What is a variable value?

  2. What is garbage value?

  3. Difference between local and global variable values?

  4. How values are passed to functions?

  5. Can variable value change during execution?

  6. 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

You may also like...