Cover Image for Keywords in C
145 views

Keywords in C

The C programming language, keywords are reserved words that have predefined meanings and cannot be used as identifiers (variable names or function names). Keywords are an essential part of the language’s syntax and semantics. Here is a list of keywords in standard C:

Plaintext
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

These keywords serve various purposes in C:

  1. Control Flow Keywords:
  • if, else, switch, case, default, for, while, do, break, continue, and return are used for controlling the flow of execution in C programs. They are essential for making decisions, looping, and branching.
  1. Data Type Keywords:
  • int, char, float, double, short, long, signed, unsigned, enum, and void are used for defining data types and variable types. For example, int is used for integer variables, float for floating-point variables, and so on.
  1. Storage Class Keywords:
  • auto, extern, static, register, and typedef are used to specify the storage class of variables and control their scope, duration, and linkage.
  1. Struct and Union Keywords:
  • struct and union are used for defining composite data types, known as structures and unions, respectively.
  1. Constant Keyword:
  • const is used to declare constants, which are values that cannot be modified after initialization.
  1. Function Declaration Keywords:
  • void is used to indicate functions that do not return a value.
  1. Pointer Keywords:
  • sizeof is used to determine the size of a data type or an expression in bytes.
  • volatile is used to indicate that a variable may be modified by external factors, such as hardware.
  1. Labels and Goto Keywords:
  • goto is used to transfer control to a labeled statement within a function.
  1. Enum Keyword:
  • enum is used to define enumeration types, which are user-defined data types that represent a set of named integer constants.
  1. Continue and Default Keywords:
    • continue is used to skip the current iteration of a loop and proceed to the next iteration.
    • default is used in switch statements to provide a default case when no other case matches.

It’s important to note that C is case-sensitive, so these keywords must be written in lowercase letters as shown above. Using keywords as variable or function names will result in compilation errors.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS