Identifiers in C

Identifier:
 
In C Programming,identifier is nothing but a user defined name given to variable,function,
structure etc.Identifier names must differ in spelling and case from any keywords.Let's understand with an example:
 
float percentage=68.69;
int rollno=13;
 
In above eg  We have defined two identifier percentage,rollno.
 
 
                

Rules for naming identifiers:

 1.The first letter of  an identifer should start either with letter or an underscore.

 2.We cannot use Keyword as an identifer.

 3.We can Use numerical value i.e 1-9 in identifier but it should start with either letter or underscore,We cannot define identifier starting with number.for eg marks1 is correct but 1marks is not correct.

4.There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.
5.It cannot have two consecutive underscores.
6.It can be a combination of numbers, letters, connectors, and Unicode characters.
7.It must start with a letter of the alphabet or an underscore, not a number.
8.It should not include white space.
9.It cannot have more than 511 characters.
10.It has to be declared before it is referred.
11.Two identifiers cannot have the same name.
12.Identifiers are case sensitive.
 
Examples of some valid identifiers:
  1. name1
  2. age_1
  3. avgofmarks
  4. _mall
Examples of invalid identifiers:
  1. 1digit(starting with numeric digit)
  2. int(Keyword)
  3. float(Keyword)
  4. n+i(special character "+" is used)
 
Types of Identifier:
 
External Identifier:If the identifier is used withinside the outside linkage, then it's far called an outside identifier. The outside identifiers may be feature names, international variables.
 
Internal Identifier:If the identifier isn't used withinside the outside linkage, then it's far referred to as an inner identifier. The inner identifiers may be neighborhood variables. 
 

Difference between   Keyword and Identifer:





The identifier is simply the title given to the variable, whilst a variable represents a reminiscence subject the place some statistics is saved primarily based on its records type. It's simply like what is the distinction between you and your name. Your title is simply a phrase that human beings name you with, whilst you are a human being.

If you any have doubt,suggestion regarding this post or website then feel free to share with us.
 
If you have learned something new from this post then share this post with your family and
friends.
 
Happy Learning :)😎  
  

Previous Next

Post a Comment

Previous Post Next Post