As we know,the smallest individual units in a program are known as tokens.Tokens is smallest unit which is easily identifies by C++ compiler.C++ has the following tokens:Keywords
Ex:- int,float,double etc.
All C keywords are valid in C++ Keywords.But C++ also contain extra keywords.Ex:- Public,Private,True,False etc.
Rules
- Identifiers
- Constants
- Strings
- Operators
Keywords
Keyword is reserve word that have predefine meaning.Keyword is a word whose meaning is already define to C++ compiler.Keywords can be written is lower case.Ex:- int,float,double etc.
All C keywords are valid in C++ Keywords.But C++ also contain extra keywords.Ex:- Public,Private,True,False etc.
Identifiers
Identifiers refer to the names of variables,Functions,arrays,classes etc.,created by the programer.They are the fundamental requirement of any language.Each language has its own rules for naming these identifiers.Rules
- Identifiers name also start from alphabet.
- No blank space allow between two words.
- No special character is allow.
- Two words are join with the help of underscore.
EX:- Valid sum and invalid 4sum.
Variables
Variables is a name that is used to by computer memory to store a value used in a program.
Ex:- a,name, sum etc.
Constants
Contants refer to fixed value that do not change during the execution of a program.
Like C,C++ supports several Kinds of literal constants,They include integers,characters,floating
point number and strings.
Integer constants :- An integer is a whole number without decimal point.It consists of sequence of digits.An integer constants must lie within the range of integer.They can be written in three different number systems:Decimal(base 10),Octal(base 8),Hexadecimal(base 19).
Ex- Valid 23 and Invalid 2,3 .
Floating point constants :- Floating point constants are used to represent real number.It contain decimal point or an exponent sign.
Ex:- 23.35 ,50.78
Character constants :- Character constants is always enclosed in a single (' ').It may be any alphabet,special character ,Digit.Do not be blank space.
Ex:- 'S','1'
String constants :- String constants is always enclosed in a double cotes (" ").It may be any alphabet,special character,digits.
Ex:- "Hello","12345"
Comments
Post a Comment