Clouds
Home
Tutorial of C language
Computer Language
Introduction to C
Programming in C
Structure of C program
Variable in C
Datatypes in C
Token in C
Operator in C
Precedence of C Operator
Assignment Operator in C
Logical Operator in C
Bitwise Operator in C
Ternary Operator in C
C Input Output
Pointers in C
Storage Classes of C
Control Structure of C
C Decision Making Statement
C Looping Statement
C Jumping Statement
C Function
Function Call By Value
Function Call By Reference
C Input Output Function
C Structure
Array in C
Union in C

Token in C

A token is a smallest or basic unit of any program. One or more characters are grouped in sequence to form a meaningful words. These meaningful words are called token. The Token in 'C' language are classified as shown below.
  • Keywords: (do, if, else, Etc.
  • Identifiers: (sum, length, i, etc)
  • Constraints: (10, 25, 0.5, etc.)
  • Operators : (*, /,%, +, -, etc)
  • Special Symbols ( (, ), [, ], {, }, ?, :, etc.)

    Keyword

  • Keywords are the words whose meaning has already been explained to the C compiler.
  • The keywords cannot be used as variable names. the keywords are also called as Reserved words.
  • Keywords are data names that have fixed meaning and these meaning cannot be changed.
  • All keywords must be written in lowercase letters.

    There are a total 32 keywords in 'C'.

  • Auto
  • Continue
  • Enum
  • if
  • short
  • switch
  • Volatile
  • Break
  • Default
  • Extern
  • int
  • signed
  • typedef
  • While
  • Case
  • Do
  • Float
  • long
  • static
  • union
  • Char
  • Double
  • For
  • register
  • struct
  • unsigned
  • Const
  • Else
  • Goto
  • return
  • switch
  • void

    Identifier

    They refer to the name of variables, functions and arrays. These are user defined names and consist of a sequence of letters and digits with a alphabet as the first character. Both uppercase and lowercase letters are permitted. The underscore is the only special character permitted in identifiers to link between two words in long identifiers. Examples: num, total , sum, gross_salary, total_income etc.

    Constant

    Constant in C refer to fixed value that do not change during program execution. 'C' supports several type of constants. They are
  • Numeric constants
  • Character constant

    Numeric Constants:

    The numeric constant is divided into two parts.
  • Integer constant: An integer constant refers to a sequence of digits. There are three types of integers namely, Decimal, Octal and Hexadecimal. Valid examples of integer constants are: { -121, 254, -13, 0, 31321, 79}. These are decimal integer constants.
  • Octal integer constant: It consists of a combination of digits from 0 to 7 with a leading zero. Examples: { 037, 0, 0551, 02342}.
  • Hexadecimal integer constant: It is preceded by ‘OX’ or ‘ox’. They may also include alphabets 'A through 'F' or 'a' through 'f' which represents the number 10 through 15. Valid hexadecimal integers are {ox2, oxbcd, OX7, ox79 etc.

    Real constant:

    The quantities represented by numbers containing fractional parts like ’18.325’. Such quantities are called real constant. Examples: {0.0075, -o.68, 231.45, 345.21}. a real number may also be expressed in exponential notation. The general form is mantissa e exponent. For example: ‘3.18E4’ is equal to 3.18 * 104.
  • Character Constant: A single character constant contains a single character enclosed in between a pair of single quote. Examples: {‘4’,’a’,’B’,’+’}. Character constants have integer values known as ASCII values. For example: the statement printf('%d',’C’); will printf( the number 67, the ASCII value of ‘C’, the converse of this is printf('%c','67'); will printf( ‘C’. This concept is useful to perform arithmetic operations on character constants.
  • String constant: A string constant is a sequence of characters enclosed in between a pair of double quotes. Examples are: {'Hello', 'GOOD MORNING', '28th April 1959', 'B'}. A single character string does not have an equivalent integer value while a single character have an integer value.
  • Backslash character constant. These character constants are also known as Escape sequences. Some of the backslash character constants are:
    '\\n' New line character
    '\\t' Horizontal tab
    '\\b' Backspace character
    '\\a' Audible alert

    Operator in C >>
    Precedence of C Operator >>
    Assignment Operator in C >>
    Logical Operator in C >>
    Bitwise Operator in C >>


    Home Clouds