Just like all languages c++ also have a well-maintained set of characters, symbols, integers, etc.
It is defined as a set of valid charac
These are the smallest individual unit in a program. There are 5 types of tokens:
The reserved word in c++, which already have some meanings are known as keywords. C++ Language supports more than 64 keywords, of which 32 are also present in C.
Every Keyword exists in lower case latter like auto, break, case, const, continue, int etc
These are used as general terminology for the names given to different parts of program viz. variables, objects, etc.
Rules for Identifiers
When naming an identifier, follow these established rules:
- An identifier cannot be a C++ keyword. Keywords have predefined special meanings to the compiler.
- It cannot have two consecutive underscores.
- It can be a combination of numbers, letters, connectors, and Unicode characters.
- It must start with a letter of the alphabet or an underscore, not a number.
- It should not include white space.
- It cannot have more than 511 characters.
- It has to be declared before it is referred.
- Two identifiers cannot have the same name.
- Identifiers are case sensitive.
iii. LITERALS- Literals are the data items that are constants i.e, they never change their value during a program run. There are several kinds of literals
1. Bool literals: It is used to represent boolean values ( true or false/0 or 1).
size required -1 bit.
2. Integer Constants: They are the whole numbers without a fractional part.
They can be of 3 types:
Rules for Integer constants
- It must have at least one digit and must not contain any decimal point.
- It may contain either + or – sign. A number with no sign is assumed to be positive.
- Commas cannot appear in integer constant.
3. Character Constants
4. String literals: String literals are enclosed in double-quotes. A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. Size of string literal is the number of characters plus 1 for the terminating null character. For example – ‘
Â If you liked my post Please share and follow me on @priya123..