Sunday 1 January 2017

Smallest Individual Unit Tokens

Share & Comment
The smallest individual unit in a program is known as a Token. 


C++ have the following tokens:

·        Keywords
·        Identifiers
·        Punctuators
·        Operators

Keywords

The keywords are the word that convey a special meaning to the language compiler.

C++ Keywords 


Identifiers

An identifier is the name given by the user for the program. Even though original C++ consider all the characters in an identifier, significant yet it is implementation depends. It varies from one version to another.

C ++ is case sensitive as it treats upper and lower case character differently. The following are some valid identifiers:

Myfile
DATE9_7_77
FILE13
Z2T0Z9
MYFILE
_DS
_CHK
_HJI3_JK

The following are some invalid identifiers:

DATA – REC
Contains Special Character
29CLCT
Starting with a digit
Break
Reserved Keyword
My.file
Contains special Character

Literals

Literals (often referred to as constants) are data items that never change their value during a program run.

C++ allows several kinds of literals:

Integer – constant
Character- constant
Floating- constant
String- literal

Punctuators

The following characters are used as punctuators also called as operators on C++

{ }        [ ]        ()         ,           ;           :           *                   =          #

This enhance a program’s readability and give proper meaning to statements, expressions etc. as per syntax.

Operators

Operators are tokens that trigger some computation or action when applied to variables and other objects in an expression.

Below listed are some operators

  • I/O Operators
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
Tags:

Written by

Hy, i am a Code Geek ! And like to eduate others.

0 comments:

Post a Comment

 
Copyright © C++ Programming | Designed by Templateism.com