Tokens of C++ language

C++ Tokens:
  • The C++ program can contain the individual units called the C++ tokens and have the following types.

1.    Keywords:
  • It is pre- defined words in C++. (i.e., Fixed words for creating programs in C++)
  • List of keywords in C++ language:
2.    Identifiers:
  • Identifiers are user-defined words in c++ program such as variable name, function name, array name and etc.
3.    Constants:
  • Its value is fixed in C++.
  • But it can be change during it’s before execution.
  • User can also create constant throw syntax.
Syntax:
Const data_type  variable_name  = value;
For example:
The pi(π) value is standard value i.e. 22/7 = 3.14.
4.    String:
  • Strings are collections of characters or alphabets i.e. words
  • It is used to display on the output screen for user understanding.
5.    Special symbols:
It has a special built-in meaning in the C++ language.
6.    Operators:
  • An operator is a symbol that specifies an operation to be performed on the operands.
  • Five kinds of operators, there are
                   1.      Arithmetic operators(+,-,*,/,%,++,--)
                   2.     Relational Operators (==,!=,<=,>=,<,>)
                   3.     Logical Operators (&&,||,!)
                   4.     Assignment Operators(=,+=,-=,*=,/=,%=)
                   5.     Conditional Operators (?:)
                      6.    Bitwise Operators(&,|,^,<<,>>)
Example program for C-Tokens
  1. #include<iostream.h>
    #include<conio.h>
    void main()
    {
    const int a=5;
    const int b=10;
    int c;
    clrscr();
    c=a+b;
    cout<<"\n Addition of a and b value is: "<<c;
    getch();
    }
Explanations:
  • Keywords - main,int,cout,clrscr,getch
  • Identifiers - a,b,c
  • Constants - a=5,b=10
  • String- cout<<“\n Addition of a and b value is: <<c;
  • Special symbols-(),{,},;,”
  • Operators -=,+
Output:
Share:

No comments:

Post a Comment

Popular Posts

Search This Blog

Powered by Blogger.

Blog Archive

Service Support

Need our help to Learn or Post New Concepts Contact me

Blog Archive

Recent Posts

Service Support

Need our help to Learn or Post New Concepts Contact me