Here you will find What is a variable in C language, Variable Definition, Variable Declaration, Variable Initialization and Rules for naming a variable in C Language
What is a Variable in C Language? | Variable Declaration and initialization.pptx
1. WHAT IS A VARIABLE?
In Mathematics, A variable is some letter which
hold some value, Like x=20. A variable’s value will
vary(change) accordingly. Variables are used in
expressions and equations.
2. WHAT IS A VARIABLE?
In Programming, A variable is a named memory
location which holds input data and its computational
results. E.g. marks = 97. It is same like a box that you
label and put some stuff into.
3. CHARACTERISTICS OF A VARIABLE?
Variables are created in RAM, So data stored in
Variables is temporary
VARIABLE DECLARATION
Writing variable name with its data type is called Variable
declaration. It tells the compiler the name of the variable
to be used in program and type of information to be stored
in it
Syntax:
Data Type Variable Name;
Example:
int marks;
float height;
char x;
int x,y,z,a,age;
C is a strongly typed language, so all variables must be
declared before being used. The compiler will report error if an
undeclared variable is used in a program.
4. VARIABLE INITIALIZATION
Assigning a value first time after Variable declaration is
called variable initialization
Syntax:
Data Type Variable Name = value;
Example:
int marks = 99;
float height;
height = 170;
5. RULES FOR FOR NAMING A VARIABLE
Variable name in C consists of letters, numbers, or
an underscore.
First character of a variable should be a letter or
underscore(_).
Keywords can not be used for variable names like
int, void etc.
Blank space between variable names is not allowed.
6. Constant
A constant is an identifier whose value cannot be changed
during program execution. E.g. PI