Overview
This lecture explains identifiers and keywords in C, discusses their differences, and outlines important rules for each, as well as their roles in C programming.
Keywords in C
- Keywords are reserved words in C with predefined meanings (e.g., int, float, break, continue, for, if, while).
- There are 32 keywords in ANSI C, standardized in 1989.
- Keywords cannot be used as identifiers (e.g., variable or function names).
- All keywords must be written in lowercase letters; C is case-sensitive.
- The meaning of keywords cannot be changed during program execution.
- Keywords are basic building blocks for writing instructions in C programs.
Identifiers in C
- Identifiers are names given by users to variables, functions, arrays, structures, or unions.
- Identifiers help uniquely identify elements in code.
- Identifiers can consist of letters, digits, and underscores, but must begin with a letter or an underscore.
- No special characters (e.g., $, %, @, -, space, dot) are allowed in identifiers.
- Identifiers are case-sensitive: sum, Sum, and SUM are different identifiers.
- Keywords cannot be used as identifiers.
- According to ANSI C, the first 31 characters of an identifier are significant.
- Both uppercase and lowercase letters are allowed in identifiers.
Differences Between Keywords and Identifiers
- Keywords are predefined and reserved; identifiers are user-defined names.
- Keywords must be lowercase; identifiers can use both cases.
- Keywords cannot be used as variable or function names; identifiers are used for that purpose.
- The meaning of keywords is fixed; identifiers' meanings are assigned by the user.
Key Terms & Definitions
- Keyword — a reserved, predefined word in C with a specific meaning (e.g., int, for, float).
- Identifier — a user-defined name for a variable, function, array, etc.
Action Items / Next Steps
- Review the rules for forming valid identifiers in C.
- Prepare for the next lesson on data types in C.
- (Optional) Comment examples of valid/invalid identifiers as discussed in the lecture.