C Token

tutorial and example
tutorial and example

                       C Token and Keyword

The C tokens are the basic buildings blocks in Clanguage which are constructed together to write a C program.

Each and every smallest individual unit in Cprogram is known as C Tokens.

There are six types of tokens in C language that are given below:

  1. Keywords
  2. Identifier
  3. Constant
  4. String
  5. Operator
  6. Punctuaton

Lets us consider an example of Token.

Keywords in C

Keyword is used to perform an internal operation. We cannot use it as the variable name, constant name etc.

Every keyword exists in lower case latter like auto, break, case etc.

There are 32 keywords in C language.

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

Identifiers in C

The identifier is a name used to identify a variables, constants, functions and user-defined data. There are following some rules for naming identifier.

  • It can only alphanumeric characters (a-z, A-Z, 0-9) and underscore

( _) symbol.

  • Identifier names must be unique.
  • The first character names must be unique.
  • We cannot use a keyword as identifiers.
  • Only first thirty-one (31) characters are significant.
  • Must not contain white spaces.
  • Identifiers are case-sensitive.

Example:

In the given above example amount and total balance are identifiers and double is a keyword.

Constant in C

Constant is a variable that value never change during execution once defined. It is also known as literals. Const keyword is used to define a constant.

 Syntax:

Example:

Strings in C

String constants are the sequence of characters enclosed within double quotes.

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

Example: