
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is an identifier and its rules in C language?
Identifier is one of the tokens which are used in C programming language. It is a name which is used to identify the variables, constants, functions, arrays, and also user-defined data.
We cannot use keywords as identifiers because keywords are reserved for special use. Once declared, we can use the identifier in later program statements which refers to the associated value.
The special kind of identifier is known as a statement label and it can be used in goto statements.
Rules
The rules for naming identifiers are as follows −
Identifier names are unique.
Cannot use a keyword as identifiers.
Identifier has to begin with a letter or underscore (_).
It should not contain white space.
Special characters are not allowed.
Identifiers can consist of only letters, digits, or underscore.
Only 31 characters are significant.
They are case sensitive.
Example
Following is the C program to identify which terms are called as identifiers −
/* C Program to Count Vowels and Consonants in a String */ #include <stdio.h> int main(){ char str[100]; int i, vowels, consonants; i = vowels = consonants = 0; printf("\nEnter any String : "); gets(str); while (str[i] != '\0'){ if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U'){ vowels++; } else consonants++; i++; } printf("\n no of Vowels in the given String = %d", vowels); printf("\n no of Consonants in the given String = %d", consonants); return 0; }
Output
When the above program is executed, it produces the following result −
Enter any String : Tutorials Point no of Vowels in the given String = 6 no of Consonants in the given String = 9
In the above program the identifiers are −
Str, i, vowels, consonants
- Related Questions & Answers
- What is an identifier in C language?
- What are the rules about using an underscore in a C++ identifier?
- What is the word OFFER and its rules?
- What are the local and global scope rules in C language?
- What is an algorithm and flowchart in C language?
- What is an anagram in C language?
- Explain variable declaration and rules of variables in C language
- What is an Acceleration Clause and what is its significance?
- What is Accountability and what is its importance in an organization?
- What is an inline function in C language?
- What is an array of structures in C language?
- What is an auto storage class in C language?
- What is an extern storage class in C language?
- What is an Absolute Advantage and what are its benefits?
- What is an Account Statement and what are its contents?