Wednesday, 21 March 2018

C++ Tokens

The smallest individual units in a program is known as Tokens.
The C++ programs are written by using these tokens , white spaces and syntax of the language.
C++ has following Tokens 
  1. Keywords
  2. Identifiers
  3. Constants
  4. Strings
  5. Operators

Keyword :-
  Keyword are those words meaning whose meaning is known to the compiler or whose meaning is already defined by compiler.
 Keywords are also called as reserved words.Keywords should not be used in variable declaration.
 Following are some example of keywords
   auto , break , case , char , class , const , continue , default,..........................................

Identifiers :-
  Identifiers refers to the name of the variables , functions , arrays , classes created by the programmer.
  Rules of Naming identifiers:-
   1. Only alphabets , digits , and underscore are permitted.
   2. Variable name should not start with digit.
   3. Uppercase and lowercase letter are distinct.
   4. Keywords should not be used as name of the identifier.
   5. 'C' recognizes 32 characters in name of the identifiers but C++ has no limit on its length.

Constant :-
  Each primitive data type has their own constant value declaration also called as literals.

Primary Constant
  a. Integer Constant
  b. Real Constant 
  c. Character Constant

Secondary Constant
  a. Array
  b. Pointer
  c. Structure and unions
  d. Enum

Primary Constant
 Integer Constant :-
   1. Integer constant must have at least one digit.
   2. They must not have a decimal point.
   3. They can be positive or negative.
   4. If there is no any sign to integer it is assume to be positive.
   5. No comma or blank spaces are allowed within the integer constant.
          e.g.  426, +756 , -588 etc.

Real Constant :-
   1. These are generally called as floating point constant.They can be written two forms.That is , fractional form & exponential form.
  2. Real constant can be positive or negative.
  3. They must have decimal point.
  4. Default sign is positive.
  5. No comma or blank spaces are allowed in the real number.
       e.g. 22.45 , -85.23 , -11.20 , +3.211e-4 , 5.6e4 etc.

Character Constant :-
   1. The character constant is a single alphabet or a single digit or s single special symbol enclosed within the single quotation marks.
   2. Maximum length of a character is one character.

0 Comments:

Post a Comment

Popular Posts

Categories

AI (33) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (146) C (77) C# (12) C++ (82) Course (67) Coursera (198) Cybersecurity (24) data management (11) Data Science (106) Data Strucures (8) Deep Learning (13) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (21) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (893) Python Coding Challenge (285) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses