
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:
- Control Flow Keywords:
if
,else
,switch
,case
,default
,for
,while
,do
,break
,continue
, andreturn
are 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
, andvoid
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.
- Storage Class Keywords:
auto
,extern
,static
,register
, andtypedef
are used to specify the storage class of variables and control their scope, duration, and linkage.
- Struct and Union Keywords:
struct
andunion
are used for defining composite data types, known as structures and unions, respectively.
- Constant Keyword:
const
is used to declare constants, which are values that cannot be modified after initialization.
- Function Declaration Keywords:
void
is used to indicate functions that do not return a value.
- 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.
- Labels and Goto Keywords:
goto
is used to transfer control to a labeled statement within a function.
- Enum Keyword:
enum
is used to define enumeration types, which are user-defined data types that represent a set of named integer constants.
- Continue and Default Keywords:
continue
is used to skip the current iteration of a loop and proceed to the next iteration.default
is used inswitch
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.