C Tokens

In this tutorial you will learn about the C Tokens and its application with practical example.

What Is Token

The smallest individual entity used in a c program is known as a token. Tokens are the various elements in a program; identified by the compiler. It can be anything that is meaningful to the compiler. Compiler parses the program and extracts the individual tokens. The tokens are the important building block of the C programming language. We can not create a c program without using c tokens.

Types of Token In C

C supports the following six types of tokens:

  • Keywords
  • Identifiers
  • Strings
  • Operators
  • Constants
  • Special Symbols

c-tokens-type

Keywords

There is a set of reserved words that you cannot use as an identifier. These words are known as “reserved words” or “Keywords”. Keywords are standard identifiers and their function and behavior are predefined by the compiler. There are 32 keywords in the C language.

Example:-

Identifiers

An identifier is a name given to program elements such as functions, variables, structures, unions, arrays, etc. It is a sequence of letters, digits, and underscores. The keywords can not be used as identifiers. The identifier must differ in spelling and case from keywords.

Example:-

Strings

String refers to a series or sequence of characters such as letters, numbers, and special characters. In C programming, string is enclosed in double-quotes(“”) and characters are enclosed in single quotes(”).

Example:-

Operators

The operator is a special symbol that is used to carry out some specific operation on its operand. In c programming, we have a rich set of built-in operators to carry out a different typess of operations. There are operators for assignment, arithmetic operations, logical operations, comparison operations, etc.

Example:-

Constants

Constants refer to immutable values. These are basically literals whose values cannot be modified or changed during the execution of the program.

Example:-

Special Symbols

The special symbols have some special meaning associated with them. They cannot be used for some other purpose except a special purpose attached to them.

Example:-

In this tutorial we have learn about the C Tokens and its application with practical example. I hope you will like this tutorial.