| |
|
C Identifiers
C identifiers will represent the name in c program and that names should be used for variables, functions, arrays, structures, unions and labels etc. And this identifiers can be composed of letters in both upper and lowercase, underscore and digits. But start should be either from composed of letters or by underscore. We cannot start this from digits that is incorrect. If identifier is not used in external linkage then it is called as an internal identifier. And in opposite if we used identifier is used in extrenal linkage then it is called external identifier.
There are 52 aplhabetical characters (26 for lower and 26 for uppercase), underscore character and ten numerical digits (0-9) which represnet the identifiers. There is a total of 63 alphanumerical characters that represent the identifiers.
Rules for create C identifiersBelow are the mainly 7 rules for creating a c identifier these are given below:-
(1)First character of an identifier should be either an alphabet or an underscore and then it is followed by any of the character, digit or underscore.
(2)We cannot use numerical digit as first character or we cannot we cannot start this from alphanumeric.
(3)We cannot use commas or blank spaces within an identifiers.
(4)We cannot use keywords as an identifier.
(5)There is limit on identifiers and should not be more than 31 characters.
(6)When we ask about identifiers both uppercase and lowercase are distinct. So we can say that identfiers are case sensitive.
(7)We must write identifiers in such way that it is meaningful , short and easy to read and view.
Valid identifiers Example
totalval,sum,_a_,sum_1,average,view_1_d etc.
Invalid identifiers Example
2sum (cannot start with numerical digit)
int (Its a reserved word)
char (Its a reserved word)
m+n (Invalid character used "+")
Types of identifiers(1)Internal Identifier
(2)External Identifier
(1)Internal Identifier:-As i have define above identifier that is not used in external linkage is known as internal identifier. And internal identifiers can be a local variables.
(2)External Identifier:-This is also define above when identifier is used in the external linkage then its known as an external identifier. Example of external identifiers can be a function name or we can say a global variables.
Keyword and Identifier Difference
There are mainly 5 main differences between keyword and identifier are given below:-
(1)Keyword is pre-defined word and identifier is user-define word.
(2)Keyword must be written in lowercase letter and identifier can be written in both lowercase and in uppercase letters.
(3)Keyword cannot contain the underscore character but identifiers can contain underscore.
(4)Keyword meaning is pre-define in C compiler but identifier cannot be define in the c compiler.
(5)Keyword is combination of alphabetical characters and identifier is combination of alphanumeric characters.
Example of Identifier are case sensitive
Output of above code:-
Value of a is : 10
Value of A is :20
In above example and output we have shows that value of both variable "a" and "A" are different that shows that identifiers are case sensitive. | |
|
|
|
|