C Keywords

Keywords in C are reserved words that have special meanings and predefined functions in the C programming language. These keywords cannot be used as identifiers (e.g., variable names, function names) because they are reserved for specific purposes. Here's a list of keywords in C:


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

Here's a brief explanation of some of the commonly used keywords:

  • auto: Declares automatic variables. This keyword has limited use in modern C programming.
  • break: Used to exit from loops (e.g., for, while, do-while) and switch statements.
  • char: Declares character variables or data types.
  • const: Indicates that a variable's value cannot be changed after initialization. It's used for creating constants.
  • continue: Used to skip the current iteration of a loop and proceed to the next iteration.
  • double: Declares double-precision floating-point variables or data types.
  • else: Part of the conditional statement (if-else) to execute code when the condition is false.
  • enum: Declares enumerated data types.
  • extern: Used for declaring variables and functions that are defined in other files or in a different scope.
  • float: Declares single-precision floating-point variables or data types.
  • for: Used for loop control, allowing you to execute a block of code repeatedly.
  • if: Used for conditional execution, allowing you to execute code based on a condition.
  • int: Declares integer variables or data types.
  • long: Declares long integer variables or data types.
  • return: Used to exit a function and return a value to the caller.
  • sizeof: Returns the size, in bytes, of a data type or variable.
  • static: Declares variables and functions with static storage duration, meaning they retain their values across function calls.
  • struct: Declares user-defined data structures.
  • switch: Used for multi-way branching, allowing you to select one of several code blocks to execute.
  • typedef: Used to create custom type definitions.
  • unsigned: Declares unsigned integer variables or data types, which can only represent non-negative values.
  • void: Indicates that a function doesn't return a value or that a pointer doesn't have a specific data type.
  • volatile: Specifies that a variable's value may change unexpectedly (e.g., due to hardware), preventing compiler optimizations.
  • while: Used for loop control, allowing you to execute a block of code repeatedly as long as a condition is true.

These keywords are an integral part of the C language, and they have specific roles and meanings that help define the structure and behavior of C programs.