Identifiers in C Language

What is an Identifier in C?

An identifier is a name given by the programmer to identify various elements of a C program. Identifiers are used to name variables, functions, arrays, pointers, structures, unions, enumerations, and other program elements. For example, total, main, student and calculateSum are identifiers.

C language is case-sensitive, which means that uppercase and lowercase letters are treated differently. Therefore, total, Total and TOTAL are three different identifiers.

C भाषा में Identifier (आइडेंटिफायर) प्रोग्रामर द्वारा प्रोग्राम के विभिन्न अवयवों की पहचान करने के लिए दिया गया नाम होता है। आइडेंटिफायर का उपयोग Variables, Functions, Arrays, Pointers, Structures, Unions, Enumerations तथा अन्य प्रोग्राम अवयवों के नाम रखने के लिए किया जाता है। उदाहरण के लिए, total, main, student और calculateSum आइडेंटिफायर हैं।

C लैंग्वेज एक Case-Sensitive भाषा है, जिसका अर्थ है कि इसमें बड़े और छोटे अक्षरों को अलग-अलग माना जाता है। इसलिए total, Total और TOTAL तीन अलग-अलग आइडेंटिफायर हैं।

Rules for Naming Identifiers in C

The following rules must be followed while creating identifiers in C language:

  1. An identifier must begin with an English alphabet (A–Z or a–z) or an underscore (_). It cannot begin with a digit.

  2. An identifier can contain letters, digits and underscores only.

  3. Blank spaces and special characters such as @, #, %, :, - and . are not allowed in an identifier.

  4. A C keyword cannot be used as an identifier.

  5. Identifiers are case-sensitive. For example, marks, Marks and MARKS are different identifiers.

  6. There is no general eight-character limit for identifiers in modern C. However, the compiler and C standard impose certain implementation limits.

  7. Meaningful names should be used to make programs easier to understand. This is a good programming practice.

C लैंग्वेज में आइडेंटिफायर का नाम बनाते समय निम्नलिखित नियमों का पालन करना चाहिए:

  1. आइडेंटिफायर का पहला अक्षर English Alphabet (A–Z या a–z) या Underscore (_) होना चाहिए। इसकी शुरुआत किसी अंक से नहीं हो सकती।

  2. आइडेंटिफायर में केवल अक्षरों, अंकों और अंडरस्कोर का उपयोग किया जा सकता है।

  3. आइडेंटिफायर में Blank Space तथा @, #, %, :, - और . जैसे विशेष चिन्हों का उपयोग नहीं किया जा सकता।

  4. C लैंग्वेज के किसी भी Keyword को आइडेंटिफायर के रूप में उपयोग नहीं किया जा सकता।

  5. आइडेंटिफायर Case-Sensitive होते हैं। उदाहरण के लिए, marks, Marks और MARKS अलग-अलग आइडेंटिफायर हैं।

  6. आधुनिक C लैंग्वेज में आइडेंटिफायर के लिए आठ अक्षरों की कोई सामान्य सीमा नहीं है। हालांकि, Compiler और C Standard के अनुसार कुछ सीमाएं निर्धारित होती हैं।

  7. प्रोग्राम को आसानी से समझने योग्य बनाने के लिए Meaningful Names का उपयोग करना चाहिए। यह एक अच्छी Programming Practice है।

Examples of Identifiers in C

1. Valid Identifiers (उचित आइडेंटिफायर)

The following are valid identifiers in C language:

int number;
float a123;
int simple_interest;
int student1;
float totalMarks;
int _count;

उपरोक्त सभी आइडेंटिफायर उचित हैं क्योंकि ये C लैंग्वेज के Naming Rules का पालन करते हैं।

Although _count is syntactically valid in this example, identifiers beginning with an underscore are reserved in certain contexts by the C standard. Beginners should preferably use names that begin with a letter.

हालांकि _count इस उदाहरण में Syntax के अनुसार सही है, लेकिन C Standard के अनुसार अंडरस्कोर से शुरू होने वाले कुछ नाम Reserved होते हैं। इसलिए शुरुआती प्रोग्रामर्स को ऐसे नामों का उपयोग करना चाहिए जिनकी शुरुआत किसी अक्षर से होती है।

2. Invalid Identifiers (अनुचित आइडेंटिफायर)

The following are invalid identifiers in C language:

float :x;
int for;
int max marks;
float 7g;
int total-marks;

Explanation:

  • :x is invalid because it contains a special character (:).

  • for is invalid because it is a C keyword.

  • max marks is invalid because it contains a blank space.

  • 7g is invalid because an identifier cannot begin with a digit.

  • total-marks is invalid because a hyphen (-) is not allowed in an identifier.

व्याख्या:

  • :x अनुचित है क्योंकि इसमें Special Character (:) का उपयोग किया गया है।

  • for अनुचित है क्योंकि यह C लैंग्वेज का Keyword है।

  • max marks अनुचित है क्योंकि इसमें Blank Space है।

  • 7g अनुचित है क्योंकि किसी आइडेंटिफायर की शुरुआत अंक से नहीं हो सकती।

  • total-marks अनुचित है क्योंकि आइडेंटिफायर में Hyphen (-) का उपयोग नहीं किया जा सकता।

Example Program Using Identifiers in C

The following C program demonstrates the use of identifiers as variable and function names.

#include <stdio.h>
int calculateSum(int a, int b)
{
int total;
total = a + b;
return total;
}
int main(void)
{
int num1 = 10;
int num2 = 20;
int result;
result = calculateSum(num1, num2);
printf("Sum = %d\\n", result);
return 0;
}

Output:

Sum = 30

In this program, calculateSum, main, a, b, total, num1, num2 and result are identifiers. They are used to identify the function, its parameters and variables.

इस प्रोग्राम में calculateSum, main, a, b, total, num1, num2 और result आइडेंटिफायर हैं। इनका उपयोग Function, उसके Parameters तथा Variables की पहचान करने के लिए किया गया है।

Important Points About Identifiers

  • Every variable name is an identifier, but every identifier is not a variable name.

  • Keywords cannot be used as identifiers.

  • Identifiers are case-sensitive.

  • Identifiers should have meaningful names.

  • An identifier must follow the naming rules of C language.

  • प्रत्येक Variable का नाम एक आइडेंटिफायर होता है, लेकिन प्रत्येक आइडेंटिफायर Variable का नाम नहीं होता।

  • Keywords का उपयोग आइडेंटिफायर के रूप में नहीं किया जा सकता।

  • आइडेंटिफायर Case-Sensitive होते हैं।

  • आइडेंटिफायर के नाम Meaningful होने चाहिए।

  • प्रत्येक आइडेंटिफायर को C लैंग्वेज के Naming Rules का पालन करना चाहिए।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Complete C Programming Syllabus | Advanced C Roadmap for Students

Top High-Paying Tech Skills to Learn in 2025