Keywords in C

Last Updated :

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.

Comment
Next Article
CPP_Programmer Published 16 Aug, 2020 · 4 min read
Article Tags :

Similar Reads

  • What should we use void main() or int main() ?

    There is question that what should we use void main() or int main() ? void main() { /* ... */ } Or, int main() { /* ... */…

    2 min read
  • C Comments

    Prerequisite – C Language Introduction C comments explain code and improve readability. These do not affect program execution. You can use comments in C to clarify code and describe…

    1 min read
  • C Programming Language Standard

    Prerequisite – C Language Introduction The C programming language has various versions: C89/C90, C99, C11, and C18. C89/C90: Released in 1989/1990. It introduced key language features. C99: This…

    2 min read
  • Features of C Programming Language

    Prerequisite – C Language Introduction C is a simple language made in 1972 by Dennis Ritchie. It’s for system programming. C has low-level memory access, basic keywords, good…

    1 min read
  • C Language Introduction

    C is a programming language developed by Dennis Ritchie in 1972. It has a significant historical impact. It was originally created at Bell Laboratories of AT&T Labs for…

    4 min read
  • Code editors

    Code editors are where programmers spend most of their time. There are two main types of code editors: IDEs and Lightweight editors. IDEs (Integrated Development Environments) IDEs (Integrated…

    1 min read