Variable of c++
int no;
float percentage;
char grade;
here, no is a variable of type int, Percentage is a variable of type float, and grade is a variable of type char.
Variable initialization
float Percentage=67.9;
char grade ='A';
here,5 is the value of int, 67.9 is the value of Percentage, A is the value of grade. Character value is always writine in single qoutes.
Rule to declared a variable
- The first letter is a variable should be alphabet or underscore (_).
- The first letter is a variable should not be digit.
- After first character it may be combination of alphabet and digit.
- Blank space are not allowed in variable name.
- Variable name should not be keywords.
Osm loke
ReplyDelete