C – Tokens and keywords

      Prev                                                                                              Next

     C tokens, Identifiers and Keywords are the basics in a C program. All are explained in this page with definition and simple example programs.

1. C tokens:

    • C tokens are the basic buildings blocks in C language which are constructed together to write a C program.
    • Each and every smallest individual units in a C program are known as C tokens.
    • C tokens are of six types. They are,
        1. Keywords               (eg: int, while),
        2. Identifiers               (eg: main, total),
        3. Constants              (eg: 10, 20),
        4. Strings                    (eg: “total”, “hello”),
        5. Special symbols  (eg: (), {}),
        6. Operators              (eg: +, /,-,*)

C tokens example program:

where,

    • main – identifier
    • {,}, (,) – delimiter
    • int – keyword
    • x, y, total – identifier
    • main, {, }, (, ), int, x, y, total – tokens

    Do you know how to use C token in real time application programs? We have given simple real time application programs where C token is used. You can refer the below C programs to know how to use C token in real time program.

Real time application C programs for your reference:

1. C program example – Real time Calculator program

2. C program example – Real time Bank Application program

2. Identifiers in C language:

    • Each program elements in a C program are given a name called identifiers.
    • Names given to identify Variables, functions and arrays are examples for identifiers. eg. x is a name given to integer variable in above program.

Rules for constructing identifier name in C:

      1. First character should be an alphabet or underscore.
      2. Succeeding characters might be digits or letter.
      3. Punctuation and special characters aren’t allowed except underscore.
      4. Identifiers should not be keywords.

3. Keywords in C language:

    • Keywords are pre-defined words in a C compiler.
    • Each keyword is meant to perform a specific function in a C program.
    • Since keywords are referred names for compiler, they can’t be used as variable name.

C language supports 32 keywords which are given below. Click on each keywords below for detail description and example programs.

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
 

      Prev                                                                                              Next

Share this C Programming tutorial with your friends

Facebook Twitter Linkedin





C Programming Tutorial | Terms of use | Suggestions/Contact Us | Disclaimer