MCS-011 Problem Solving and Programming

First year, Semester 1

Chapters

Newsletter

Identifiers and Keywords

Identifiers are the names given to various program elements such as constants, variables, function names and arrays etc. Every element in the program has its own distinct name but one cannot select any name unless it conforms to valid name in C language. Let us study first the rules to define names or identifiers.

Rules for Forming Identifiers

Identifiers are defined according to the following rules:

  1. It consists of letters and digits.
  2. First character must be an alphabet or underscore.
  3. Both upper and lower cases are allowed. Same text of different case is not equivalent, for example: TEXT is not same as text.
  4. Except the special character underscore ( _ ), no other special symbols can be used.

For example, some valid identifiers are shown below:  
X
X123
_XI
temp
tax_rate 

For example, some invalid identifiers are shown below:
123                     First character to be alphabet.
“X.”                    Not allowed.
order-no     Hyphen allowed
error flag     Blankspace allowed


Keywords  

Keywords are reserved words which have standard, predefined meaning in C. They cannot be used as program-defined identifiers.

The lists of C keywords are as follows:

char, while, do, typedef, auto, int, if, else, switch, case, printf, double, struct, break, static, long, enum, register, extern, return, union, const, float, short, unsigned, continue, for, signed, void, default, goto, sizeof, volatile .

Note: Generally all keywords are in lower case although uppercase of same names can be used as identifiers

Report an issue

Reporting: Identifiers and Keywords (topic)

Related Posts