- C Programming Tutorial
- C - Home
- Basics of C
- C - Introduction
- C - Features
- C - Basics
- C - History
- C - Structure of C Program
- C - Program Structure
- C - Hello World
- C - Compilation Process
- C - Comments
- C - Tokens
- C - Keywords
- C - Identifiers
- C - User Input
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Integer Promotions
- C - Type Conversion
- C - Type Casting
- C - Booleans
- Constants and Literals in C
- C - Constants
- C - Literals
- C - Escape sequences
- C - Format Specifiers
- Operators in C
- C - Operators
- C - Arithmetic Operators
- C - Relational Operators
- C - Logical Operators
- C - Bitwise Operators
- C - Assignment Operators
- C - Unary Operators
- C - Increment and Decrement Operators
- C - Ternary Operator
- C - sizeof Operator
- C - Operator Precedence
- C - Misc Operators
- Decision Making in C
- C - Decision Making
- C - if statement
- C - if...else statement
- C - nested if statements
- C - switch statement
- C - nested switch statements
- Loops in C
- C - Loops
- C - While loop
- C - For loop
- C - Do...while loop
- C - Nested loop
- C - Infinite loop
- C - Break Statement
- C - Continue Statement
- C - goto Statement
- Functions in C
- C - Functions
- C - Main Function
- C - Function call by Value
- C - Function call by reference
- C - Nested Functions
- C - Variadic Functions
- C - User-Defined Functions
- C - Callback Function
- C - Return Statement
- C - Recursion
- Scope Rules in C
- C - Scope Rules
- C - Static Variables
- C - Global Variables
- Arrays in C
- C - Arrays
- C - Properties of Array
- C - Multi-Dimensional Arrays
- C - Passing Arrays to Function
- C - Return Array from Function
- C - Variable Length Arrays
- Pointers in C
- C - Pointers
- C - Pointers and Arrays
- C - Applications of Pointers
- C - Pointer Arithmetics
- C - Array of Pointers
- C - Pointer to Pointer
- C - Passing Pointers to Functions
- C - Return Pointer from Functions
- C - Function Pointers
- C - Pointer to an Array
- C - Pointers to Structures
- C - Chain of Pointers
- C - Pointer vs Array
- C - Character Pointers and Functions
- C - NULL Pointer
- C - void Pointer
- C - Dangling Pointers
- C - Dereference Pointer
- C - Near, Far and Huge Pointers
- C - Initialization of Pointer Arrays
- C - Pointers vs. Multi-dimensional Arrays
- Strings in C
- C - Strings
- C - Array of Strings
- C - Special Characters
- C Structures and Unions
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Self-Referential Structures
- C - Lookup Tables
- C - Dot (.) Operator
- C - Enumeration (or enum)
- C - Structure Padding and Packing
- C - Nested Structures
- C - Anonymous Structure and Union
- C - Unions
- C - Bit Fields
- C - Typedef
- File Handling in C
- C - Input & Output
- C - File I/O (File Handling)
- C Preprocessors
- C - Preprocessors
- C - Pragmas
- C - Preprocessor Operators
- C - Macros
- C - Header Files
- Memory Management in C
- C - Memory Management
- C - Memory Address
- C - Storage Classes
- Miscellaneous Topics
- C - Error Handling
- C - Variable Arguments
- C - Command Execution
- C - Math Functions
- C - String Functions
- C - Static Keyword
- C - Random Number Generation
- C - Command Line Arguments
C Programming - C Keywords
![]() Share with a Friend |
C Programming - C Keywords
C Keywords
C keywords are reserved words predefined by the language and have a special meaning to the compiler. They cannot be used as identifiers (e.g., variable names, function names). Keywords help define the structure and functionality of a program.
List of Keywords in C
Below is the list of the 32 standard keywords in C:
| 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 |
Categories of Keywords
- Data Types
- Define variable types.
- Examples: int, float, double, char, void
- Control Flow
- Used for decision-making and loops.
- Examples: if, else, switch, case, for, while, do, break, continue
- Storage Classes
- Define the scope and lifetime of variables/functions.
- Examples: auto, static, extern, register
- Modifiers
- Modify the behavior of variables.
- Examples: short, long, signed, unsigned
- Special Purpose
- Serve specific tasks.
- Examples: sizeof, typedef, volatile, return, goto
- Structure and Union
- Define compound data types.
- Examples: struct, union
- Enumeration
- Used for enumerated types.
- Example: enum
Key Points About C Keywords
- Case Sensitivity:
- All keywords in C are lowercase.
- For example, Int or INT is not the same as int.
- Reserved Words:
- Keywords cannot be redefined or used as identifiers.
Example (Invalid Code):
int while = 5; // Error: 'while' is a keyword
- Extensions in C:
- The C standard has 32 keywords, but some compilers add extra keywords (e.g., asm, inline).
- Proper Usage:
- Ensure keywords are used in their correct context.
Examples of Keywords in Code
Control Flow Keywords
#include <stdio.h>
int main() {
int num = 10;
if (num > 5) { // 'if' and 'else' are control flow keywords
printf("Number is greater than 5.\n");
} else {
printf("Number is 5 or less.\n");
}
return 0; // 'return' is a keyword
}
Data Type and Modifier Keywords
#include <stdio.h>
int main() {
unsigned int age = 25; // 'unsigned' and 'int' are keywords
printf("Age: %u\n", age);
return 0;
}
Storage Class Keywords
#include <stdio.h>
void demoFunction() {
static int counter = 0; // 'static' is a storage class keyword
counter++;
printf("Counter: %d\n", counter);
}
int main() {
demoFunction();
demoFunction();
return 0;
}
Summary
- Definition: Keywords are reserved words with special meaning to the compiler.
- Usage: Keywords must be used appropriately to avoid errors.
- Restrictions: Cannot be used as variable names, function names, or other identifiers.
- Purpose: Keywords form the core syntax and structure of C programming.
