Ads block

Banner 728x90px

C Tokens

Tokens is the most important element to be used in creating a program in C. We can defined the tokens as the smallest individual element in C.

We can say that tokens in C is the building block or the basic component for creating a program in C language


Classification of tokens in C

Tokens in C language can be divided into the following categories-

  • Keywords in C
  • Identifiers in C
  • Strings in C
  • Operators in C
  • Constant in C
  • Special characters in C

Keywords in C

Keywords are pre-defined or pre-reversed words and having some special meaning. We cannot use these keywords as a variable names. If we use these words as a variable names, it means we are trying to change its special meaning.

C language supports 32 keywords given below.

autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
constfloatshortunsigned
continueforsignedvoid
dowhileifgoto
staticdefaultvolatilesizeof

Identifiers in C

Identifiers are used for naming variables, functions, arrays, structures, etc. Identifiers in C are the user-defined words. It can be composed of uppercase letters, lowercase letters, underscore, or digits. Identifiers cannot be used as keywords.
Rules for naming identifiers in C are given below:

  • The first character of an identifier should be either an alphabet or an underscore.
  • It should not begin with any numerical digit.
  • Identifiers are case sensitive.
  • Identifier must be unique.
  • Commas or blank spaces cannot be specified within an identifier.
  • Keywords cannot be represented as an identifier.
  • The length of the identifiers should not be more than 31 characters.

Strings in C

String is an one-dimensional array of characters having null character '\0' at the end of the string. This null character is used for terminate array. Strings in C are enclosed within double quotes, while characters are enclosed within single characters. The size of a string is a number of characters that the string contains.

Constant in C

A constant is value assigned to the variable that will never change during the program execution. It means the value remain unchanged.
There are two ways to declare a constant.

  • Using const keyword
const int PI=3.14;

We can use variable PI anywhere in the program.

  • Using #define pre-processor
#define PI 3.14;

It is another way to make a constant variable. PI will remain same during the execution of program.

Operator in C

C operators are symbols that are used to perform mathematical or logical manipulations. The C programming language is rich with built-in operators. These operators are applied on operands. An operand is a data item at which operation is performed. On the basis of numbers of operand, operators are classified into two categories.

1. Unary Operator

A unary operator is an operator applied to the single operand. For example: increment operator (++), decrement operator (--), sizeof, (type)*.

2. Binary Operators

The binary operator is an operator applied between two operands. The following is the list of the binary operators:

  • Arithmetic Operators
  • Relational Operators
  • Shift Operators
  • Logical Operators
  • Bitwise Operators
  • Conditional Operators
  • Assignment Operator
  • Misc Operator