๐ C Keywords – Reserved Words You Can’t Use as Names
C keywords are reserved words that have special meaning to the C compiler. These words are part of the language syntax, so you cannot use them as variable names, function names, or identifiers.
๐ List of Common C Keywords
Here are some commonly used C keywords:
- auto
- break
- case
- char
- const
- continue
- default
- do
- double
- else
- enum
- extern
- float
- for
- goto
- if
- int
- long
- register
- return
- short
- signed
- sizeof
- static
- struct
- switch
- typedef
- union
- unsigned
- void
- volatile
- while
๐ Example: Using Some C Keywords
Here’s a basic program that uses int
, return
, if
, and else
.
#include <stdio.h> int main() { int number = 10; if (number > 0) { printf("The number is positive.\n"); } else { printf("The number is not positive.\n"); } return 0; }
โ What You Shouldn’t Do
You cannot use C keywords as variable names. For example, this will throw an error:
int return = 5; // โ Error: 'return' is a keyword
๐ง Quick Tips
- Keywords are case-sensitive in C (e.g.,
int
is valid,Int
is not a keyword). - You can use underscores or different names:
returnValue
, notreturn
.
๐ฏ Practice Idea
Try writing a program using 5 different C keywords. Can you use for
, if
, int
, return
, and break
together?