How To Declare Variables In C++?
Assigning the name and data type that a variable can hold is called declaration of variable. All variables that are used in a program are declared using variable declaration statement.
type list of variables;
where
type
specifies data types of variables.
list of variables
specifies a list of variables separated by commas.
To declare variables a and xy as input type, b as float type, nm as string type of 15 characters and sum as double, the statements are written as
int a, xy;
float b;
char nm [15];
double sum;
Note: To print the contents stored in a variable, the variable name is given in the output ( i.e cout) statement without quotes.