Programming in C: Unit I (b): Introduction to C

Identifiers

C Program

Identifiers, as the name suggests, help us to identify data and other objects in the program. Identifiers are basically the names given to program elements such as variables, arrays, and functions.

IDENTIFIERS

Identifiers, as the name suggests, help us to identify data and other objects in the program. Identifiers are basically the names given to program elements such as variables, arrays, and functions. Identifiers may consist of sequence of letters, numerals, or underscores.

Rules for Forming Identifier Names

Some rules have to be followed while forming identifier names. They are as follows:

• Identifiers cannot include any special characters or punctuation marks (like #, $, ^, ?,., etc.) except the underscore’_’

• There cannot be two successive underscores.

• Keywords cannot be used as identifiers.

• The case of alphabetic characters that form the identifier name is significant. For example, 'FIRST' is different from 'first' and 'First'.

• Identifiers must begin with a letter or an underscore. However, use of underscore as the first character must be avoided because several compiler-defined identifiers in the standard C library have underscore as their first char- acter. Hence, inadvertently dupli- cated names may cause definition conflicts.

Programming Tip: C is a case sensitive language. If you type printf function as Printf, then an error will be generated.

• Identifiers can be of any reasonable length. They should not contain more than 31 characters. They can actually be longer than 31, but the compiler looks at only the first 31 characters of the name.

Although it is a good practice to use meaningful identifier names, it is not compulsory. Good identifiers are descriptive but short. To cut short the identifier, you may use abbreviations. C allows identifiers (names) to be up to 63 characters long. If a name is longer than 63 characters, then only the first 31 characters are used.

As a general practice, if the identifier is a little long, then you may use an underscore to separate the parts of the name or you may use capital letters for each part. Examples of valid identifiers include:

roll_number, marks, name, emp_number, basic_ pay, HRA, DA, dept code, Dept Code, RollNo, EMP NO

Examples of invalid identifiers include:

23_student, %marks, @name, #emp_number, basic.pay, -HRA, (DA), &dept_code, auto

Note

C is a case-sensitive language. Therefore rno, Rno, RNo, RNO are considered as different identifiers.

Programming in C: Unit I (b): Introduction to C : Tag: : C Program - Identifiers


Programming in C: Unit I (b): Introduction to C



Under Subject


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation



Related Subjects


Professional English II

HS3251 2nd Semester 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Statistics and Numerical Methods

MA3251 2nd Semester 2021 Regulation M2 Engineering Mathematics 2 | 2nd Semester Common to all Dept 2021 Regulation


Engineering Graphics

GE3251 eg 2nd semester | 2021 Regulation | 2nd Semester Common to all Dept 2021 Regulation


Physics for Electrical Engineering

PH3202 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Basic Civil and Mechanical Engineering

BE3255 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Electric Circuit Analysis

EE3251 2nd Semester 2021 Regulation | 2nd Semester EEE Dept 2021 Regulation


Physics for Electronics Engineering

PH3254 - Physics II - 2nd Semester - ECE Department - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Electrical and Instrumentation Engineering

BE3254 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Circuit Analysis

EC3251 - 2nd Semester - ECE Dept - 2021 Regulation | 2nd Semester ECE Dept 2021 Regulation


Materials Science

PH3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd semester Mechanical Dept | 2021 Regulation | 2nd Semester Mechanical Dept 2021 Regulation


Physics for Civil Engineering

PH3201 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Basic Electrical, Electronics and Instrumentation Engineering

BE3252 2021 Regulation | 2nd Semester Civil Dept 2021 Regulation


Physics for Information Science

PH3256 2nd Semester CSE Dept | 2021 Regulation | 2nd Semester CSE Dept 2021 Regulation


Basic Electrical and Electronics Engineering

BE3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation