Professional Documents
Culture Documents
Lecture - 3DIT 1, C&C++)
Lecture - 3DIT 1, C&C++)
Lecture - 3DIT 1, C&C++)
IT-I
VARIABLE:-
It is a piece of primary memory (RAM) of the computer where the data can be stored by the user. The name which
is given to the piece of memory for its calling etc. is called variable name or identifier. As given
Variable or identifier
The basic purpose of variable is that the user can store data any if he/she wants.
1) INTEGER DATA TYPE VARIABLE:- it is used to store numeric data without floating point. For example
1, 454 and 44 etc. the total size of integer data type is 2 byte. The int keyword is used for integer data
type variable.
2) FLOAT DATA TYPE VARIABLE:- it is used to store numeric data with floating point. For example 3.4,
556.7 and 1.0 ect. The total size of floating data type variable is 4 bytes. The float keyword is used for
floating data type variable.
3) CHARACTER DATA TYPE VARIABLE: - it is used to store any type of character as numeric, alphabetic or
special. The total size of character data type is 1 byte which is equal to 8 bits. The char keyword is used for
character data type.
4) BOOLEAN DATA TYPE VARIABLE: - It is used to store Boolean data. As 1 or 0. 1 is used for TRUE or ON
while 0 is used for FALSE or OFF. The total size of Boolean data type variable is 1 bit.
VARIABLE DECLARATION:-
Giving name and data type to a variable is called variable declaration. The compiler reserves specific location in the
memory for the declared variable.
Datatype variable_name;
Example:
int a;
int a,b,c;
The data can be stored in a variable in two ways. It may be Static or dynamic
STATIC: When the data is stored in a variable during coding is called static. As lets we have integer variable and
named “a”.
a=34;
DYNAMIC: when the data is stored in a variable during running time of the program is called dynamic. In C
language the scanf keyword is used and C++ the cin keyword is used as
cin>>a;