Keywords and Itentifier
Keywords are the words whose meaning has already defined to the C compiler (or in a broad sense to the computer).
These keywords cannot be used as variable names because if we do
so we are trying to assign a new meaning to the keyword, which is
not allowed by the C compiler.
The keywords are also called as Reserved words. There are only 32 keywords available in C language. These keywords are mentioned below:
We will use and learn these above keywords in our program whenever required.
Identifier is the unique name given to entities such as variables, functions, structures, etc. They are created to identify entities during the execution of program. For example:
Here, acountNumber and balance are the identifiers. Keep in the mind that the name of identifiers must be different from keywords. You can't use int as an identifier because int is a reserved keywords of C compiler.
Identifiers are a part of the Basic Programming Elements of the C Programming Language while Variables, Constants, Literals, etc. are other Basic Elements / Sub-Elements. Without a proper understanding these identifier the C Language cannot be understand properly. Same as for other Programming Language, because these Basic Elements are equally exist not only in C Language but any other Programming Language.
Rules for naming identifiers
- Any upper case and lower case character can be used in the name of any identifier.
- Underscore can also be used in the name of any identifier.
- If we want to use digits in the name of any identifier, it is necessary to have at least one character or underscore before using the digits.
- Apart from this, any type of Special Symbol such as Period, Comma, Blank Space etc. cannot be used in the name of the identifier. Also, we cannot use the name of a Reserve Word or a Built-In Function in the name of an identifier.
- The name of identifier cannot be starts with a digit.
- Reserved keyword cannot be used as identifier.
"C" is a case sensitive language, so the names of capital letters and small letters are considered as different in this language. Like int Sum and int sum are two different variable name or identify and not same.
Right way to declare variable identifier
We can name any variable identifier or constant identifier in any of the following ways, which completely follow the naming conventions of "C":
Wrong way to declare variable identifier
The below names are declared wrong and we cannot accept the names of these types to any variable or constant identifier, because these names do not follow the naming rules of "C" Language:
|number#||illegal use of special symbol #|
|number2*||illegal use of special symbol *|
|1amount_of_sale||name could not start with a digit|
|&$amount||illegal use of special symbol & and $|
|days Of Week||illegal use of special symbol blank space|
|months OfYear10||illegal use of special symbol blank space|