C Programming Language
  • Home
  • C Fundamentals
    • C Character Set
    • Tokens>
      • Keywords
      • Identifiers
      • Constants>
        • Definition and Its types
        • Numeric Constants>
          • Integer Constants
          • Real Constants
        • Character Constants
        • String Constants
        • Backslash Character
      • Operators>
        • Definition and Its types
        • Arithmetic
        • Relational
        • Logical
        • Increment
        • Decrement
        • Assignment
        • Arithmetic Assignment
        • Conditional
        • Bitwise
        • Special Operators
        • Hierarchy
    • Data Types>
      • Primary (Or) Basic
      • User-Defined
      • Derived
    • Variable>
      • Definition
      • Declaration
      • Initialization
  • Control Structures
    • Decision-Control>
      • If Statement>
        • Simple-if Statement
        • if-else Statement
        • Nested-if Statement
        • if-else ladder Statement
      • Switch Statement
    • Loop Control>
      • For
      • While
      • Do-While
  • Arrays
    • Introduction
    • Single-Dimensional>
      • Definition
      • Declaration
      • Initialization
    • Two-Dimensional>
      • Definition
      • Declaration
      • Initialization
    • Multi-Dimensional>
      • Definition
      • Declaration
      • Initialization
  • Functions
    • Definition
    • Standard Library Character Functions
    • Standard Library String Functions
    • Storage Classes>
      • Definition
      • Automatic
      • Register
      • Static
      • External
  • Pointers
  • Files
    • Concepts
    • Data Files and its Categories
    • Standard Files and its Categories
  • University Questions
    • April 2001 To 2005
    • April 2006 To 2010
    • April 2011 To 2015
    • November 2001 To 2005
    • November 2006 To 2010
    • November 2011 To 2015
Keywords

C programs are constructed from a set of reserved words which provide control and from libraries which perform special functions. 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., C demands that they are used only for giving commands or making statements. You cannot use default, for example, as the name of a variable. An attempt to do so will result in a compilation error.

Keywords have standard, predefined meanings in C. These keywords can be used only for their intended purpose; they cannot be used as programmer-defined identifiers.  Keywords are an essential part of a language definition. They implement specific features of the language. Every C word is classified as either a keyword or an identifier. A keyword is a sequence of characters that the C compiler readily accepts and recognizes while being used in a program. Note that the keywords are all lowercase. Since uppercase and lowercase characters are not equivalent, it is possible to utilize an uppercase keyword as an identifier.

  • The keywords are also called ‘Reserved words’.
  • Keywords are the words whose meaning has already been explained to the C compiler and their meanings cannot be changed.
  • Keywords serve as basic building blocks for program statements.
  • Keywords can be used only for their intended purpose.
  • Keywords cannot be used as user-defined variables.
  • All keywords must be written in lowercase.
  • 32 keywords available in C.

Data types        Qualifiers           User-defined           Storage Classes          Loop                Others          

int                       signed                 typedef                      auto                                    for                    const
char                   unsigned            enum                        extern                                 while                volatile
float                   short                                                       register                              do                     sizeof
double              long                                                        static                          

Decision            Jump              Derived         function

if                           goto                struct              void
else                     continue         union             return
switch                 break                                     
case                                                               
default                                               

Restrictions apply to keywords

  • Keywords are the words whose meaning has already been explained to the C compiler and their meanings cannot be changed.
  • Keywords can be used only for their intended purpose.
  • Keywords cannot be used as user-defined variables.
  • All keywords must be written in lowercase.
Data type Keywords

int                 Specifies the integer type of value a variable will hold
char             Specifies the character type of value a variable will hold
float             Specifies the single-precision floating-point of value a variable will hold
double         Specifies the double-precision floating-point type of value a variable will

Qualifier Keywords

signed         Specifies a variable can hold positive and negative integer type of data
unsigned    Specifies a variable can hold only the positive integer type of data
short            Specifies a variable can hold fairly small integer type of data
long             Specifies a variable can hold fairly large integer type of data

Loop Control Structure Keywords

For                  Loop is used when the number of passes is known in advance
While              Loop is used when the number of passes is not known in advance
Do                   Loop is used to handle menu-driven programs

User-defined type Keywords

typedef           Used to define a new name for an existing data type
Enum             Gives an opportunity to invent own data type and define what values the variable of this data type can take

Jumping Control Keywords

Break             Used to force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop
continue        Used to take the control to the beginning of the loop bypassing the statements inside the loop
Goto               Used to take the control to required place in the program

Storage Class Keywords

Storage Classes            Storage                            Default initial value                      Scope                             Life

auto                                   Memory                         An unpredictable value                  Local             Till the control remains within the block
register                            CPU registers            Garbage value                                  Local             Till the control remains within the block
static                                Memory                         Zero                                                   Local             Value of the variable persists between different function calls
extern                               Memory                        Zero                                                   Global            Till the program’s execution doesn’t come to an end

Review Questions

Part - A
1.    Define Keyword.
2.    List any four key words of C language.
3.    What are keywords? Give examples.
4.    What are the restrictions apply for keywords?
5.    List any four keywords (Reserved words) of C language

Part - B
1.    Write short notes on: keywords (Reserved words) in C
2.    State the meaning of the following keywords in C: auto, double, int, long


Powered by Create your own unique website with customizable templates.