Keywords in C

By | August 16, 2020

A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows:

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

Keywords


Keywords are already defined by Compiler that cannot be used as Variable Name, so keywords are also called as reserved words. The basic instructions are built up using a reserved set of words, such as main, for, if, while, default, double, extern, for, and int, etc. There are 32 Keywords in C.

Properties of Keywords in C :

  1. Keywords have standard, predefined meanings in C.
  2. These cannot be used as programmer-defined identifiers.
  3. These implement specific features of the language.

There are 32 Keywords in C

Note that the keywords are all lowercase and C is case sensitive language so Same toke in Upper case be used as an identifier.

1. Data type Keywords :

  • int
    Represents variable that has value integer type.
  • char
    Represents variable that has value character type.
  • float
    Represents variable that has value single-precision floating-point type.
  • double
    Represents variable that has value double-precision floating-point type.

2. Qualifier Keywords :

  • signed
    Represent variable that can have value of positive and negative integer type.
  • unsigned
    Represent variable that has only positive integer type value.
  • short
    Represent variable that has fairly small integer type value.
  • long
    Represent variable that has fairly long integer type value.

3. User-defined type Keywords :

  • typedef
    It is used to define a new name for an existing data type.
  • enum
    It is used to declare new enumeration types. It is mainly used to assign names to integral constants.

4. Storage class Keywords :

  • auto
    To assign memory, with initial unpredictable value. It has local scope.
  • register
    To assign CPU register, with initial garbage value. It has also local scope.
  • static
    To assign memory, with initial value 0. It has local scope but its value of the variable persists between different function calls.
  • extern
    To assign memory, with initial value 0. It has global scope.

5. Loop control structure Keywords :

  • for
    This loop is used when the number of passes is known in advance.
  • while
    This loop is used when the number of passes is not known in advance.
  • do
    This is used to handle menu-driven programs

6. Decision making Keywords :

  • if
    It is used to execute or skip a statement by checking a condition.
  • else
    It is used when first part of “if” is not true.
  • switch
    It is used to test various cases by using switch cases.
  • case
    A case is used to represent a case or expression that should be executed when “switch” statement takes control in it.
  • default
    It is default “case” in “switch” statement, it executed when no other “cases” are true or not present.

7. Jumping control Keywords :

  • break
    It is used to terminate a loop by force, and bypasses its remaining conditional expression and any remaining code in the body of the loop.
  • continue
    It is used to take the control to the beginning of the loop bypassing the statements inside the loop.
  • goto
    It is used to take the control to required place in the program

8. Derived Keywords :

  • struct
    It defines a new data type, with more than one member of possibly different types into a single type.

  • union
    It is same as “struct”, but only one member can contain a value at any given time.

9. Function Keywords :

  • void
    The void keyword meaning nothing or no value. void testFunction(int a) function cannot return a value because its return type is void.

  • Return
    The return keyword terminates the function and returns the value.

10. Other Keywords :

  • const
    It is used to declarer that variable to specify that its value will not be changed

  • volatile
    It is used to inform the compiler that the variable value can be changed any time without any task given by the source code.

  • sizeof
    It is a compile-time unary operator and used to compute the size of its operand. It is most common operator and can be applied to any data type, float type, pointer type variables. It returns the size of a variable.



Please write comments if you find anything incorrect. A gentle request to share this topic on your social media profile.