Difference Between Keywords and Identifiers
The main difference between keywords and identifiers is that a keyword can contain only the alphabet, whereas an identifier can contain alphabets, digits, and underscores. The differences between the two are essential parts of the GATE CSE syllabus.
Key Differences Between Keywords and Identifiers
It should always be in lowercase.
It can be in lower case or upper case.
It has a predefined meaning. They are reserved for use by the user.
It has no meaning attached to it. Usually, an identifier is a name provided by the user.
No special symbol is used.
Except for the underscore, no other special symbol is used.
It specifies the type of entity.
It gives a name to the type of entity.
Example: void, int, signed, etc.
Example: test, _abc, etc.
What is a Keyword in C?
Keywords are predefined reserved words present to the user in the C language. Any C program must have keywords present in it. In fact, a program in C begins with the keyword itself. The keyword is a type of C token which is used for formulating various problems in the GATE question paper.
In C, there are 32 reserved words or keywords present. Keywords are used in functions, blocks, loops, user-defined data structures, etc. The keywords are as follows: auto, default, float, register, struct, volatile, break, do, for, return, switch, while, char, else, if, signed, union, case, double, goto, short, typedef, const, enum, int, sizeof, unsigned, continue, extern, long, static, void.
What is an Identifier in C?
An identifier is a name given to memory space or a function for future reference in the program. An identifier does not have predefined meanings. They are user-defined names composed of letters and digits.
For an identifier to be valid, we need to follow the predefined rules to declare an identifier that is an identifier should only begin with a letter or an underscore and not by any digit. Identifiers are essential for the GATE exam. It cannot contain any special symbol other than letters, digits, or underscore.
Check out the following topics related to the difference between keywords and identifiers: