Assume that your version of C can recognize only the first 8 characters of an identifier name, though identifiernames may be arbitrarily long. Which of the following pairs of identifier names are considered to be identical andwhich are distinct?(a) name, names (6) l i s t l , l i s t 2( b ) address, Address ( e ) answer, ANSWER(c) i d e n t i f i e r - 1 , i d e n t i f i e r - 2 CI) c h a r l , char-1
Question
Assume that your version of C can recognize only the first 8 characters of an identifier name, though identifiernames may be arbitrarily long. Which of the following pairs of identifier names are considered to be identical andwhich are distinct?(a) name, names (6) l i s t l , l i s t 2( b ) address, Address ( e ) answer, ANSWER(c) i d e n t i f i e r - 1 , i d e n t i f i e r - 2 CI) c h a r l , char-1
Solution
(a) The identifier names "name" and "names" are considered to be distinct because they differ in the 6th character.
(b) The identifier names "address" and "Address" are considered to be distinct because they differ in the 1st character.
(c) The identifier names "identifier-1" and "identifier-2" are considered to be distinct because they differ in the 9th character, which is beyond the limit of 8 characters.
(d) The identifier names "charl" and "char-1" are considered to be distinct because they differ in the 5th character.
Similar Questions
Determine which of the following are valid identifiers. If invalid, explain why.(a) r e c o r d 1 ( e ) $ t a x ( h ) name-and-address(b) l r e c o r d cr) name (i) name-and-address(c) f i l e - 3 (g) name and address (j) 123 - 45 - 6789(6) r e t u r n
Choose a valid identifier name according to the naming rules of the C language.
n any language, we learn words after learning the alphabet. We use words to name and identify different things. These names are nothing but Identifiers.Identifiers are names used to refer to any entity in a program. (A program can contain many entities (or building blocks) such as data types, constants, variables, functions, arrays, etc. We shall learn about them in the later sections.)An identifier is a sequence of characters. In C, identifiers can be formed by combining alphabets, digits and a special character underscore '_' .For example, consider the program given below:#include <stdio.h>void main() { printf("Hello!");}The tokens main and printf are the names of two functions and are called identifiers.Given below are the rules for creating a valid identifier in C:The first character must always be an alphabet or an underscore. The remaining characters can be a combination of one or more alphabet, digits, and underscores. No special characters except the underscore are allowed in an identifier.An identifier can be of any length. However, in old C (before C was standardized by ANSI), only the first 8 characters were considered by the compilers when the names were compared for equality. This limit was later changed to 31 characters as per the ANSI standard.Click on Live Demo to test and verify the rules for creating valid identifiers in C.Select the correct statements from the given statements.InDia is a valid identifier.Codetantra-software is a valid identifier.An identifier is a sequence of alphabet only._File123 is not a valid identifier._File124_ is not a valid identifier.
What is an identifier in C language?
Which of the following is an invalid identifier in C?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.