Keywords and Identifiers in C Language
To write programs, every programming language provides some pre-defined words.
That means the programming language defines and reserves certain words
specifically for writing programs.
In this topic, we will learn about such words.
Keywords in C Language
Keywords are reserved words that have fixed, built-in meanings.
In C, there are a total of 32 reserved keywords.
These keywords cannot be used as variable names or function names.
Example: int, float, double, char, return
Points About Keywords
- Fixed Meaning: Each keyword instructs the C compiler to perform a specific action, define a data type, or control the flow of the program.
-
Case-Sensitive:
Keywords must be written only in lowercase
(for example:
intis a keyword, butINTis not).
Identifiers in C Language
Identifiers are the names given to variables, functions, arrays, and structures.
They help the programmer easily refer to program elements
while writing and understanding the program.
Example: quantity, price, salary, marks
Naming Rules
- Must start with a letter or an underscore
- Must not start with a number
- Can contain only letters (A–Z, a–z), digits (0–9), and underscores (_)
- Must not use keywords
- Must not use special symbols
- Case-sensitive (for example:
quantityandQuantityare different)
Examples
Valid: quantity, _price, mark1, total_marks
Invalid: 2mark, int, total-salary, total@marks
Key Difference Between Keyword and Identifier
Keywords → Predefined words with special meaning for the compiler (e.g., int, float).
Identifiers → Names given by the programmer (e.g., quantity, salary).
The following program demonstrates the use of keywords and identifiers in C Language
#include<stdio.h>
int main() {
int mark1 = 70;
int mark2 = 80;
int total;
total = mark1 + mark2;
printf("total:%d", total);
return 0;
}
Output:
total:150
total:150
In the above program,
-
Keywords (predefined words)
int→ A keyword that specifies the integer data type.return→ A keyword that indicates the end of function execution.- These are predefined words in C and cannot be used as variable names.
-
Identifiers (names given by the programmer)
mark1,mark2,total→ Names given to variables (identifiers).
So far, we have learned:
- Keywords and Identifiers
- How to write a program using Keywords and Identifiers
- In the next topic, we will learn about Scope of Variables.