Computer Science: Introduction to C + +: Tokens and Identifiers

Doorsteptutor material for UGC is prepared by world's top subject experts: Get complete video lectures from top expert with unlimited validity: cover entire syllabus, expected topics, in full detail- anytime and anywhere & ask your doubts to top experts.

Download PDF of This Page (Size: 134K)

Tokens

  • A token is a group of characters that logically belong together. The programmer can write a program by using tokens.

  • C++ uses the following types of tokens.

Image of Tokens in C++

Image of Tokens in C++

Image of Tokens in C++

Keywords

There are some reserved words in C++ which have predefined meaning to complier called keywords.

Some commonly used keywords are given below:

Image of Keywords

Image of Keywords

Image of Keywords

Identifiers

  • Symbolic names can be used in C++ for various data items used by a programmer in his program. For example, if a programmer wants to store a value 50 in a memory location, he/she choose any symbolic name (say MARKS) and use it as given below:

  • MARKS = 50

  • The symbol ‘=’ is an assignment operator.

  • The significance of the above statement is that ‘MARKS’ is a symbolic name for a memory location where the value 50 is being stored.

  • A symbolic name is generally known as an identifier. The identifier is a sequence of characters taken from C++ character set.

The rules for the formation of an identifier are:

  • An identifier can consist of alphabets, digits and/or underscores.

  • It must not start with a digit.

  • C++ is case sensitive, i.e., upper case and lower-case letters are considered different form each other. It may be noted that TOTAL and total are two different identifier names.

  • It should not be a reserved word.

Developed by: