C++ Tokens

 The smallest individual unit in a program is known as token. These elements help us to construct statements, definitions, declarations, and so on, which in turn helps us to construct complete program.

Tokens used in C++ are

1. Identifier
2. Reserved Keywords
3. Constants or Literals
4. Punctuators
5. Operators

 Identifiers
       Identifiers is a name given to programming elements such as variables, functions, arrays, objects, classes, etc. It contains letters, digits and underscore. C++ is a case sensitive; it treats uppercase and lowercase characters differently.

Rules to be followed while creating identifiers

1. Identifiers are a sequence of characters which should begin with the alphabet either from A-Z (uppercase) or a-z (lowercase) or _ (underscore).
2. C++ treats uppercase and lowercase characters differently. For example, DATA is not same as data.
3. No Special character is allowed except underscore “_”.
4. Identifier should be single words i.e. blank spaces cannot be included in identifier.
5. Reserved Keywords should not be used as identifiers.
6. Identifiers should be of reasonable length.

Keywords
    Keyword is a predefined word that gives special meaning to the complier. The programmer is not allowed to change its meaning. These are reserve for special purpose and must not be used as identifier name.  Example: for, if, else, this, do, float, while, switch etc.

Constants
      A constant are identifiers whose value does not change during program execution. Constants are sometimes referred to as literal.

Punctuators 
       Punctuators in C++ have syntactic and semantic meaning to the compiler.  Some punctuators can be either alone or in combination. The characters are used as punctuators which are also known as separators in C++.

C++ Operators
        An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and there are almost 45 different operators.Operators in C++ are can be divided into the following classes:
1. Arithmetic Operator
2. Relational Operator
3. Logical Operator
4. Unary Operator
5. Conditional Operator
6. Bitwise Operator
7. Assignment Operator
8. Other Operator
C++ Tokens C++ Tokens Reviewed by Unknown on 04:31 Rating: 5

No comments:

Powered by Blogger.