PROGRAMMING FUNDAMENTALS 2.2
VARIABLES Variable is a named location in a memory where a program can manipulate the data This location is used to hold the value of the variable. This value may change in the program. “In short, a variable is a place to store a piece of information. Just as you might store a friend’s phone number in your own memory.”
Variables should be declared in the C program before being used.
Memory space is not allocated for a variable while declaration. It happens only on the variable definition.
Syntax: data_type variable_name;
Example command to declare variable: int marks;
Figure 2.1: Example of Data Types and Variables
Variable initialization means assigning a value to the variable.
Syntax: data_type variable_name = value;
20 | P a g e