2.B) Explain the various rules for forming identifier names. Give examples of valid and
invalid identifiers names for the same.
Answer:-
Rules for forming identifier names:-
- Identifier should contain only alphabets (A-Z), (a-z), numerals(0-9) and underscore (_)
- The identifier should start with alphabet or underscore, but not a numeric character
- The first 31 characters in an identifier are significant, the rest of characters are neglected
- No reserve words (keywords) of C language can be used as identifiers
- Identifiers are case sensitive
Examples of valid identifiers:-
food, counter_7, max_1, min_1
Examples of Invalid identifiers:-
$num //$ is special character
int //keyword
name 1 //space not allowed