In C++ Programming language variable is used to store data in memory location.
Rules of Declaring variables in C++
- Variable name can consist of Capital letters A-Z, lowercase letters a-z, digits 0-9, and the underscore character.
- The first character must be a letter or underscore.
- Blank spaces cannot be used in variable names.
- Special characters like #, $ are not allowed.
- C++ keywords can not be used as variable names.
- Variable names are case sensitive.
- A variable name can be consist of 31 characters only if we declare a variable more than 1 characters compiler will ignore after 31 characters.
Variable Definition in C++
Syntax:type variable_name;
type variable_name, variable_name, variable_name;
/* variable definition and initialization */
int width, height=5;
char letter='A';
float age, area;
double d;
/* actual initialization */
width = 10;
age = 26.5;
No comments:
Post a Comment