Keywords in C
Keywords are nothing but just some words that are predefined in the C compiler that has special meanings for each keyword. These meanings can not be changed. C has a total of 32 keywords. So far we have used some keyword in our previous Hello World program. like main, return, int, etc. See below the full list of keywords in the table below:
The remain keywords that we didn’t use in any previous example, we will use it in further lessons. For now, just review the reserved keywords. Remember that reserved keywords can not be used in identifiers naming. Now let’s see what is an identifier and why keywords can not be used in identifiers.
Identifiers in C
Identifiers are the user-defined data in C. We already leaned whats are identifiers. Declaring variables, declaring functions are basically called identifiers. As identifiers are defined by the coder, that’s why there are some rules for naming an identifier.
The rules of naming identifiers are similar to naming variables that we have learned in the variable lesson. But variables are a superset of identifiers. Because identifiers are also self-defined or it is named by the user.
Rules for naming identifiers:
- Keywords are not allowed to be used as identifiers.
- Identifiers can contain only underscore and alphanumeric characters.
- The first character must be an underscore or alphabet
- White space is not allowed for naming identifiers
- Every individual identifier must be unique
- Identifiers are case-sensitive
- Special characters like comma, semicolon, etc are not allowed.
If we want to declare a variable, then we must follow the rules of identifiers naming. Because variables are subset of identifiers.
char myVariable = "Hello PrograCoding!";
hin the above string variable we followed the rules of identifier while naming the variable name: myVariable