C++ Tokens: Tokens in C++ can be defined as the smallest building block (or) the smallest unit in C++ program. Each word and punctuation can be referred to as a token in C++.
In C++ language we are having different tokens. They are as follows:
Identifiers are used for naming the variables, functions, and arrays. And we cannot use the keyword for identifiers, they are designed for special use. Once if an identifier is declared we can’t define them in the later program statements for referring to associated values. And a special kind of called the “statement label” can be used in goto statements.
The identifiers can be defined in the form of long sequence letters, digits (or) by using underscore(_).
Keywords are nothing but the predefined (or) reserved words in the programming language. And each keyword is meant to perform a specific task and its meaning cannot be changed. These keywords are already known to the compiler. C++ is having more keywords than the C language.
C++ consists of totally 31 keywords. They are as follows:
Constants are similar to the variables. The main difference between them is the value of constant will be never changed once declared. Constants refer to fixed values. These are also known as “literals”.
Syntax: const data_type variable_name;
const data_type *variable_name;
Constants are of different types. They are as follows:
1) Integer constants:
2) Real (or) Floating Point Constants:
Example: 0.0, 153.56, 24896.32415
3) Octal & Hexadecimal Constants:
octal: (013 )8 = (11)10
Hexadecimal:(013)16 = (19)10
4) Character constants: ‘a’, ‘A’, ‘d’
5) String constants:
Operators in C++ are nothing but special symbols used for performing a particular task. They can perform mathematical (or) logical operations.
Different types of operators present in C++ are as follows:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operator
- Unary operator
- Ternary or Conditional Operator
- Misc Operator
Strings are nothing but can be defined as a sequence of characters enclosed in double quotes, and includes letters, digits, special characters, and blank spaces. In strings, there is a difference between ” ” and ‘ ‘.
Syntax: datatype string;