Declaration Of Variables:
Assigning the name and data type that a variable can hold is called declaration of the variable.All variables that are used in a program are declared using variable declaration statement.
The syntax to declare a variable in c++ is:
type list of variables;
where
type:
specifies data type of variables.For example,it may be int,float,etc.
list of variables:
specifies a list of variables separated by commas. In a single statement more than one variables,separated by commas, of same data type can b declared.
int abc ,xyz ,d w,A;
To declare variables a and xy as int type,w as float type,nm as string type of 15 characters and sum as double, the statments are written as:
int a,xy;
float b;
char nm [15];
double sum;
Assigning the name and data type that a variable can hold is called declaration of the variable.All variables that are used in a program are declared using variable declaration statement.
The syntax to declare a variable in c++ is:
type list of variables;
where
type:
specifies data type of variables.For example,it may be int,float,etc.
list of variables:
specifies a list of variables separated by commas. In a single statement more than one variables,separated by commas, of same data type can b declared.
Different statements are used to declare variables of different data type.
For example, to declare variables"abc","xyz","w"and "A" of integer type the statement is written as:
int abc ,xyz ,d w,A;
To declare variables a and xy as int type,w as float type,nm as string type of 15 characters and sum as double, the statments are written as:
int a,xy;
float b;
char nm [15];
double sum;
Comments
Post a Comment