๐Ÿ”‘ C Keywords โ€“ Reserved Words in C Programming

๐Ÿงฒ Introduction โ€“ What Are Keywords in C?
Keywords in C are reserved words predefined by the language that have special meaning to the compiler. These words are part of the C syntax and cannot be used for naming variables, functions, or identifiers. They are essential for writing syntactically valid C programs and form the backbone of C language constructs like data types, control statements, and loops.

๐ŸŽฏ In this guide, youโ€™ll learn:

  • The list of standard C keywords and their purpose
  • How keywords are used in program structure
  • Why you cannot redefine or use them as identifiers
  • The difference between keywords and identifiers

๐Ÿ“‹ What Are C Keywords?

Keywords are built-in, reserved terms that are used to perform specific operations or define language constructs. The C compiler interprets them as commands rather than user-defined names.


๐Ÿ“š List of ANSI C (C89/C90) Keywords

KeywordPurpose
autoDeclares automatic storage class
breakExits from a loop or switch
caseDefines a case in a switch block
charDeclares a character variable
constDeclares a constant value
continueSkips to the next loop iteration
defaultDefault case in a switch block
doLoop that executes at least once
doubleDeclares a double precision float
elseExecutes if if is false
enumDeclares an enumeration
externDeclares an external variable
floatDeclares a floating-point variable
forLooping construct
gotoJumps to a labeled statement
ifConditional execution
intDeclares an integer variable
longDeclares a long integer
registerDeclares a register variable
returnReturns from a function
shortDeclares a short integer
signedDeclares a signed variable
sizeofReturns the size of a variable
staticDeclares a static variable
structDeclares a structure
switchMulti-way branching
typedefDefines a new name for a type
unionDeclares a union type
unsignedDeclares an unsigned variable
voidDeclares functions with no return
volatileDeclares a volatile variable
whileLooping construct

๐Ÿงช Keywords Introduced in C99

KeywordPurpose
inlineSuggests that a function be inlined
_BoolBoolean data type
_ComplexComplex number type
_ImaginaryImaginary number type
restrictOptimizes pointer usage in functions

๐Ÿงช Keywords Introduced in C11

KeywordPurpose
_AlignasAligns variables in memory
_AlignofReturns alignment requirement of a type
_AtomicAtomic access for variables
_GenericEnables generic programming
_NoreturnIndicates functions that do not return
_Static_assertCompile-time assertion
_Thread_localDeclares thread-local storage

โš ๏ธ Rules for Using Keywords

  • โŒ Cannot be used as variable, function, or identifier names
  • โœ… Must be written in lowercase (e.g., int, not Int)
  • โœ… Cannot be redefined or overridden
  • โœ… Are recognized by the compiler as special symbols

โœ… Examples of Keyword Usage

int main() {
    int age = 30;      // 'int' is a keyword
    if (age > 18) {    // 'if' and 'return' are keywords
        return 1;
    }
    return 0;
}

๐Ÿ“Œ Summary โ€“ Recap & Next Steps

C keywords are reserved identifiers with fixed meanings that define how your program works. From declaring variables and types to controlling program flow, keywords play a vital role in every C application.

๐Ÿ” Key Takeaways:

  • C has 32 keywords in ANSI C, more in later versions like C99 and C11.
  • Keywords are case-sensitive and cannot be used as identifiers.
  • They are fundamental to all C syntax and logic structures.
  • Knowing how and when to use keywords is essential for proper code flow.

โš™๏ธ Real-World Relevance:

A strong grasp of C keywords enables efficient and error-free coding. They are foundational in systems programming, embedded development, and any C-based application.


โ“ Frequently Asked Questions (FAQ)

โ“ How many keywords are there in C?

โœ… The original ANSI C (C89/C90) standard includes 32 keywords. C99 and C11 standards added additional keywords like _Bool, inline, _Atomic, and others.


โ“ Can I use a keyword as a variable name?

โœ… No. Keywords are reserved and cannot be used for variable, function, or macro names. Doing so will cause a compilation error.


โ“ Are C keywords case-sensitive?

โœ… Yes. C is a case-sensitive language. Int, INT, and int are treated as different. Only int is recognized as a valid keyword.


โ“ Can keywords be redefined or overridden?

โœ… No. Keywords have predefined meaning in the C language and cannot be redefined, overridden, or changed in any way.


โ“ What is the difference between a keyword and an identifier?

โœ… A keyword is a reserved word used by the C language (e.g., return, int), while an identifier is a name defined by the programmer (e.g., count, age).


โ“ Are keywords the same across all C compilers?

โœ… All standard-compliant C compilers support the official list of keywords for each C version (C89, C99, C11). Some may include non-standard extensions, but these are not portable.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

๐Ÿ”‘ C Keywords

Or Copy Link

CONTENTS
Scroll to Top