NCERT Computer: Chapter 7 – Introduction to C + + Part 3

Download PDF of This Page (Size: 227K)

5 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.

1 Keywords

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

Some commonly used keywords are given below:

2 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.