C Tokens

In a passage of text, individual words and punctuation marks are called tokens or lexical units. Similarly, the smallest individual unit in a c program is known as a token or a lexical unit. C tokens can be classified as follows:

  1. Keywords
  2. Identifiers
  3. Constants
  4. Strings
  5. Special Symbols
  6. Operators

C Keywords

C keywords are the words that convey a special meaning to the c compiler. The keywords cannot be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed.

The list of C keywords is given below:

auto break case char const
continue default do double else
enum extern float for goto
if int long register return
short signed sizeof static struct
switch typedef union unsigned void
volatile while

C Identifiers

Identifiers are used as the general terminology for the names of variables, functions and arrays. These are user defined names consisting of arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character.

There are certain rules that should be followed while naming  c identifiers:

  •  They must begin with a letter or underscore(_).
  •  They must consist of only letters, digits, or underscore. No other special character is allowed.
  • It should not be a keyword.
  • It must not contain white space.
  • It should be up to 31 characters long as only first 31 characters are significant.

Some examples of c identifiers:

Name Remark
_A9 Valid
Temp.var Invalid as it contains special character other than the underscore
void Invalid as it is a keyword

C Constants

C constants refers to the data items that do not change their value during the program execution. Several types of C constants that are allowed in C are:

1. Integer Constants

Integer constants are whole numbers without any fractional part. It must have at least one digit and may contain either + or – sign. A number with no sign is assumed to be positive.

There are three types of integer constants:

1.1. Decimal Integer Constants

Integer constants consisting of a set of digits, 0 through 9, preceded by an optional – or + sign.

Example of valid decimal integer constants
341,  -341,  0,  8972

1.2. Octal Integer Constants

Integer constants consisting of sequence of digits from the set 0 through 7 starting with 0 is said to be octal integer constants.

Example of valid octal integer constants
010,  0424,  0,  0540

1.3. Hexadecimal Integer Constants

Hexadecimal integer constants are integer constants having sequence of digits preceded by 0x or 0X. They may also include alphabets from A to F representing numbers 10 to 15.

Example of valid hexadecimal integer constants
0xD, 0X8d, 0X, 0xbD

It should be noted that,  octal and hexadecimal integer constants are rarely used in programming.

2. Real Constants

The numbers having fractional parts are called real or floating point constants. These may be represented in one of the two forms called fractional form or the exponent form and may also have either + or – sign preceding it.

Example of valid real constants in fractional form or decimal notation
0.05, -0.905, 562.05, 0.015

Representing a real constant in exponent form

The general format in which a real number may be represented in exponential or scientific form is

mantissa e exponent

The mantissa must be either an integer or a real number expressed in decimal notation.
The letter e separating the mantissa and the exponent can also be written in uppercase i.e. E
And, the exponent must be an integer.

Examples of valid real constants in exponent form are:
252E85, 0.15E-10,  -3e+8

3. Character Constants

A character constant contains one single character enclosed within single quotes.

Examples of valid character constants
‘a’ , ‘Z’,  ‘5’

It should be noted that character constants have numerical values known as ASCII values, for example, the value of ‘A’ is 65 which is its ASCII value.

Escape Characters/ Escape Sequences

C allows us to have certain non graphic characters in character constants. Non graphic characters are those characters that cannot be typed directly from keyboard, for example, tabs, carriage return, etc.

These non graphic characters can be represented by using escape sequences represented by a backslash() followed by one or more characters.

NOTE: An escape sequence consumes only one byte of space as it represents a single character.

Escape Sequence Description
a Audible alert(bell)
b Backspace
f Form feed
n New line
r Carriage return
t Horizontal tab
v Vertical tab
\ Backslash
Double quotation mark
Single quotation mark
? Question mark

String Constants

String constants are sequence of characters enclosed within double quotes. For example,

Every sting constant is automatically terminated with a special character ‘’ called the null character which represents the end of the string.

For example, “hello” will represent “hello” in the memory.

Thus, the size of the string is the total number of characters plus one for the null character.

Special Symbols

The following special symbols are used in C having some special meaning and thus, cannot be used for some other purpose.

[] () {} , ; : * … = #

Braces{}: These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.

Parentheses(): These special symbols are used to indicate function calls and function parameters.

Brackets[]: Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.

C Operators

C operators are symbols that triggers an action when applied to C variables and other objects. The data items on which operators act upon are called operands.

Depending on the number of operands that an operator can act upon, operators can be classified as follows:

  1. Unary Operators: Those operators that require only single operand to act upon are known as unary operators.
  2. Binary Operators: Those operators that require two operands to act upon are called binary operators.
  3. Ternary Operators: These operators requires three operands to act upon.

3 Responses

  1. Tatanprasad mohapatra
    Tatanprasad mohapatra September 20, 2013 at 4:55 pm | | Reply

    I can solve my problem eassyly for this infermation provied site.

  2. Amol Malge
    Amol Malge February 8, 2014 at 2:12 am | | Reply

    Information is good but Language is litrally hard

  3. kirandeep
    kirandeep March 24, 2014 at 9:49 am | | Reply


Please comment with your real name using good manners.

Leave a Reply