InterviewSolution
| 1. |
C Identifiers |
|
Answer» C 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 DifferenceThere 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. |
|