
420 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 whileThese keywords serve various purposes in C:
- Control Flow Keywords:
if,else,switch,case,default,for,while,do,break,continue, andreturnare used for controlling the flow of execution in C programs. They are essential for making decisions, looping, and branching.
- Data Type Keywords:
int,char,float,double,short,long,signed,unsigned,enum, andvoidare used for defining data types and variable types. For example,intis used for integer variables,floatfor floating-point variables, and so on.
- Storage Class Keywords:
auto,extern,static,register, andtypedefare used to specify the storage class of variables and control their scope, duration, and linkage.
- Struct and Union Keywords:
structandunionare used for defining composite data types, known as structures and unions, respectively.
- Constant Keyword:
constis used to declare constants, which are values that cannot be modified after initialization.
- Function Declaration Keywords:
voidis used to indicate functions that do not return a value.
- Pointer Keywords:
sizeofis used to determine the size of a data type or an expression in bytes.volatileis used to indicate that a variable may be modified by external factors, such as hardware.
- Labels and Goto Keywords:
gotois used to transfer control to a labeled statement within a function.
- Enum Keyword:
enumis used to define enumeration types, which are user-defined data types that represent a set of named integer constants.
- Continue and Default Keywords:
continueis used to skip the current iteration of a loop and proceed to the next iteration.defaultis used inswitchstatements 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.