• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » C++ » Oops » What do you means by C++ Tokens? Explain Variable,Data Type,Constants, Identifiers and Keyword
Next →
← Prev

What do you means by C++ Tokens? Explain Variable,Data Type,Constants, Identifiers and Keyword

By Dinesh Thakur

As we know that Software is a Program. And a Program is that which Contains set of instructions, and an Instruction contains Some Tokens. So Tokens are used for Writing the Programs the various Types of Tokens those are contained by the Programs.

As in the English language, in a paragraph all the words, punctuation mark and the blank spaces are called Tokens. Similarly in a C++ program all the C++ statements having Keywords, Identifiers, Constants, Strings, Operators and the Special Symbols are called C++ Tokens. C++ Tokens are the essential part of a C++ compiler and so are very useful in the C++ programming. A Token is an individual entity of a C++ program.

For example, some C++ Tokens used in a C++ program are:

Reserve: words long, do if, else etc.

Identifiers: Pay, salary etc.

Constant: 470.6,16,49 etc.

Strings: “Dinesh”, “2013-01” etc.

Operator: +, *, <, >=, &&,11, etc

Special symbols: 0, {}, #, @, %, etc.

Variable: A variable is used for storing a value either a number or a character and a variable also vary its value means it may change his value Variables are used for given names to locations in the Memory of Computer where the different constants are stored. these locations contain Integer ,Real or Character Constants.

For Naming a Variable There are Some Specific Rules

• A Variable name is any Combination of 1 to 8 alphabets digits or underscore.

• The First Character in the Variable name must be an alphabet

• No Commas or blanks spaces are allowed in variable name

• No Special Symbols are used in the name of the Variable.

Character Set:- A character set denotes any Alphabet or the Special Symbol that is used for representing the Information Like In C we uses Alphabets, digits and many Types of special Symbols

                For Ex: in Alphabets we use A B …..Z or a b ……z

                in Digits        we use 1 2 3 etc

                Special Symbols  * ( ) _ # etc. 

Data Type : Every variable has a data type which denotes the type of data which a variable will hold There are many built in data types in the c language those are following as

1) Int (integer)

2) Char (character)

3) float

4) double

5) Long 

Constants: Constants, also known as literals: The term constants or literals refers to the fixed value means a Constant is that whose value is never changed at the end of the program.

            for ex:

            3x+2y=10

 Here 3 and 2 and 10 are constants their value never be change but here x and y are the variables and may be they vary their value

 There are two types of Constants in c Language.

          1) Primary Constants

          2) Secondary Constants

The Primary and Secondary Constants are further divided into the other Categorized

In Primary these are

Numeric Constants

Numeric constants refer to the numbers consisting of a sequence of digits (with or without decimal point) that can be either positive or negative. However, by default, numeric constants are positive. Numeric constants can be further classified as integer constants and floating-point constants, which are listed in Table

                 Type of Numeric Constants

Character Constants

Character constants refer to a single character enclosed in single quotes (‘ ‘). The examples of character constants are ‘f’, ‘M’, ‘8 ‘, ‘& ‘, ‘7 ‘, etc. All character constants are internally stored as integer values.

Character constants can represent either the printable characters or the non-printable characters. The examples of printable character constants are ‘ a ‘ , ‘ 5 ‘ , ‘#’ , ‘ ; ‘ etc. However, there are few character constants that cannot be included in a program directly through a keyboard such as backspace, newline and so on. These character constants are known as non-printable constants and are included in a program using the escape sequences. An escape sequence refers to a character preceded by the backslash character (\). Some of the escape sequences used in C++ is listed in Table

                                Escape sequences Character

String Constants

String constants refer to a sequence of any number of characters enclosed in the double quotes (” “). The examples of string constants are “hello” , “name”, “colour”, “date”, etc. Note that string constants are always terminated by the Null ( ‘\ 0 ‘ ) character.

The presence of a backs lash character in a string constant indicates an escape sequence. For example, the string constant “welcome \ “home” is displayed as welcome” home. Note that the double quote next to the backslash is an escape sequence and not a delimiter for the string constant.

In Secondary these are

 

          1) Array

          2) Pointer 

          3) Structure

          4) Union

          5) Enum or Enumeration.

For Making or Declaring a Integer Constant There are some Specific Rules like

 

•    An Integer Constant must have at Least one Digit

•    it must not have a Decimal value

•    it could be either positive or Negative

•    if no sign is Specified then it should be treated as Positive

•    No Spaces and Commas are allowed in Name

•    The Range of Integer Constant is -32768 to 32767

 

For Making or Declaring Real constant there are some Specific Rules like

 

•    A Real Constant must have at Least one Digit

•    it must have a Decimal value

•    it could be either positive or Negative

•    if no sign is Specified then it should be treated as Positive

•    No Spaces and Commas are allowed in Name

 

In The Exponential Form of Representation the Real Constant is represented in the two Parts The part before appearing e is called mantissa whereas the part following e is called Exponent.

 

•    In Real Constant the Mantissa and Exponent Part should be separated by letter e

•    The Mantissa Part has may have either positive or Negative Sign

•    Default Sign is Positive

•    The Range of Real Constant is -3.4e38 to 3.4e38

 

For Making or Declaring a Character Constant there are some Specific Rules like

 

 A Character is Single Alphabet a single digit or a Single Symbol that is enclosed within Single inverted commas.

         • It must not have a Decimal value

         • The Range of Character is -128 to 127

Identifiers The Identifiers are those which are used for giving a name to a variables, arrays, functions, classes, structures, namespaces and so on, like a b etc these are used for naming a variable. When we declare any variable then we specify a Name So that identifiers are used for naming a variable.

While defining identifiers in C++, programmers must follow the rules listed here .


• An identifier must be unique in a program .
• An identifier must contain only upper case and lower case letters, underscore character (_) ordigits 0 t0 9.

• An identifier must start with a letter or an underscore.
• An identifier in upper case is different from that in lower case.
• An identifier must be different from a keyword. In addition, identifiers that start with a double underscore ‘_’ or an underscore followed by an upper case letter must be avoided as these names are reserved by the Standard c++ Library.
• An identifier must not contain other characters such as ‘*’, ‘;’ and whitespace characters (tabs, space and newline).

 

Some valid andinvalid identifiers inC++ are listed here.

 

Po178_ddm     //valid
_78hhvt4        //valid
902gt1            //invalid as it starts with a digit
Tyy;ui8          //invalid as it contains the ‘;’ character
for                   //invalid as it is a c++ keyword
Fg026 neo     //invalid as it contains spaces

 

Keywords : A Keyword is that which have a special meaning those are already been explained to the c++ language  like cout, cin, for, if, else , etc these are the reserve keywords Always Remember that we can t give a name to a variable as the name of a keyword we cant create new Keywords in c Language. All the keywords of C++ are listed in Table.

                  Keyword in C ++ Programming Language

Operator: –An Operator is a Special Symbol, which is used for performing an Operation. So that Operator is that which have a Special Meaning and also have a Sign For Example we know that + is used for Adding two Numbers.

Depending on the number of operands and function performed, the C++ operators can be classified into various categories. These include arithmetic operators, relational operators, logical operators,’ the conditional operator, assignment operators, bitwise operators and other operators. These categories are further classified into unary operators, binary operators and ternary operators.

                            Types of Operators

Statement: A Statement is that which Contains constants, variable, and also Some Operators for Example 2a+3b=146; is a Statement because in this 2, 3 and 146 are the constants and the + and = are operators and a and b are the variables. Always remember that a Statement always ends with a Semicolon. If you forgot the Semicolon at the end of the Statement then this will gives us the error.
Punctuators, also known as separators, are the tokens that serve different purposes based on the context in which they are used. Some punctuators are used as operators, some are used to demarcate a portion of the program and so on. The various punctuators defined in C ++ are asterisk ‘*’, braces ‘{ }’, brackets ‘[]’, colon ‘:’, comma ‘,’, ellipsis ‘ … ‘, equal to ‘=’, semicolon ‘;’, parentheses ‘()’ and pound (hash) ‘#’.

 

You’ll also like:

  1. Constants – Type of Constants in C++
  2. What is Key words?Explain Type of Keyword
  3. Data Types – Explain Data Type in C++.
  4. Explain C# Data Type
  5. What is Constants? Type of constant
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

C++ Tutorials

C++ Tutorials

  • C++ - Data Types
  • C++ - Operators Types
  • C++ - CPP Program Structure
  • C++ - Conditional Statements
  • C++ - Loop
  • C++ - do-While Loop
  • C++ - Control Statements
  • C++ - Tokens
  • C++ - Jump Statements
  • C++ - Expressions
  • C++ - Constants
  • C++ - Character Set
  • C++ - Iteration Statements
  • C++ - I/O Statements
  • C++ - String
  • C++ - Manipulators

C++ Operator

  • C++ - Input/Output Operator
  • C++ - Operator Overloading

C++ Functions

  • C++ - Functions
  • C++ - Member Functions
  • C++ - Returning Object from Function
  • C++ - Call by Value Vs Reference
  • C++ - Friend Function
  • C++ - Virtual Function
  • C++ - Inline Function
  • C++ - Static Data Members
  • C++ - Static Member Functions

C++ Array & Pointer

  • C++ - Array
  • C++ - Array of Objects
  • C++ - Arrays as Class Members
  • C++ - Vector
  • C++ - Pointer
  • C++ - 'this' Pointer

C++ Classes & Objects

  • C++ - Class
  • C++ - Program Structure With Classes
  • C++ - OOP’s
  • C++ - Objects as Function Arguments
  • C++ - Procedure Vs OOL
  • C++ - Object Vs Class
  • C++ - Creating Objects
  • C++ - Constructors
  • C++ - Copy Constructor
  • C++ - Constructor Overloading
  • C++ - Destructor
  • C++ - Polymorphism
  • C++ - Virtual Base Class
  • C++ - Encapsulation

C++ Inheritance

  • C++ - Inheritance
  • C++ - Multiple Inheritance
  • C++ - Hybrid Inheritance
  • C++ - Abstraction
  • C++ - Overloading

C++ Exception Handling

  • C++ - Exception Handling
  • C++ - Templates
  • C++ - Standard Template Library

C++ Data Structure

  • C++ - Link List

C++ Programs

  • C++ Program for Electricity Bill
  • C++ Program for Multiply Matrices
  • C++ Program for Arithmetic Operators
  • C++ Program For Matrices
  • C++ Program for Constructor
  • C++ Program Verify Number
  • C++ Program Array Of Structure
  • C++ Program to find Average Marks
  • C++ Program Add And Subtract Matrices
  • C++ Program Menu Driven
  • C++ Program To Simple Interest
  • C++ Program To Find Average
  • C++ program exit()
  • C++ Program Using Array Of Objects
  • C++ Program Private Member Function
  • C++ Program To Reverse A String
  • C++ Program to Operator Overloading

Other Links

  • C++ - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW