Identifiers in C Programming MCQ Questions and Answers
1. Which of the following is a valid identifier in C?
A) 2count
B) _total
C) int
D) for-loop
[Answer:] B
2. In C, identifiers are:
A) Case-insensitive
B) Case-sensitive
C) Always uppercase
D) Always lowercase
[Answer:] B
3. Which of the following is not a valid identifier?
A) sum_of_values
B) value#1
C) value1
D) _value
[Answer:] B
4. Which one of these is a keyword and therefore cannot be used as an identifier?
A) unsigned
B) counter
C) Index
D) _temp
[Answer:] A
5. Which rule about identifiers is true in standard C?
A) Identifiers may contain letters, digits, and underscores only.
B) Identifiers may contain hyphens.
C) Identifiers may contain spaces.
D) Identifiers may start with a digit.
[Answer:] A
6. Which identifier is reserved for the implementation (compiler/library) and should be avoided for user-defined names?
A) temp_var
B) _myvar
C) __libfunc
D) Var1
[Answer:] C
7. Which of the following is the best description of an identifier?
A) A constant numeric value in a program
B) A name used to identify a variable, function, or macro
C) A type qualifier
D) A preprocessor directive
[Answer:] B
8. Which identifier will conflict with a standard library name and is therefore not recommended?
A) printf
B) print_count
C) main_counter
D) printCount
[Answer:] A
9. Which of the following is true about identifiers beginning with a single underscore followed by a lowercase letter (e.g., _x) in standard C?
A) They are always illegal.
B) They are reserved for use by the implementation in the global namespace.
C) They are only reserved inside functions.
D) They are always safe to use as global variable names.
[Answer:] B
10. Which of the following identifiers is valid in C but may be considered poor style because it resembles a keyword?
A) for
B) For
C) goto
D) goto_label
[Answer:] D
11. Which identifier would follow recommended naming practice for a constant macro?
A) maxItems
B) MAX_ITEMS
C) max_items
D) Maxitems
[Answer:] B
12. Which of the following is true about using Unicode characters in identifiers in modern C (C11 and later)?
A) Standard C guarantees full Unicode identifier support.
B) Identifiers must be ASCII only.
C) Extended character sets may be supported but are implementation-defined.
D) Unicode punctuation is allowed in identifiers.
[Answer:] C
13. Which of the following is a correct statement about identifier length in C?
A) C guarantees unlimited significant identifier length.
B) Only the first character of an identifier matters.
C) The standard requires a minimum number of significant initial characters, but the exact limit may vary by implementation.
D) Identifiers are limited to 8 characters in all compilers.
[Answer:] C
14. What will happen if you attempt to declare two variables with the same identifier in the same block?
A) The compiler will silently pick one.
B) It’s allowed — variables are merged.
C) It causes a compilation error (redefinition).
D) It creates two separate variables with the same name.
[Answer:] C
15. Which of the following statements about scope and identifiers is correct?
A) An identifier declared inside a block is visible globally.
B) Block-scoped identifiers are visible only within that block and nested blocks.
C) Function parameters are not identifiers.
D) Identifiers are always visible throughout the file.
[Answer:] B
16. Which of the following is an example of a valid function name (identifier) in C?
A) 1stFunction
B) _init
C) break
D) void
[Answer:] B
17. Which of these is true regarding identifier starting characters?
A) An identifier can start with a digit.
B) An identifier must start with a letter or underscore.
C) Identifiers must start with uppercase letters.
D) Identifiers must start with lowercase letters.
[Answer:] B
18. Which identifier is most likely to be reserved by the implementation and should not be defined by a user program?
A) _myTemp (single underscore + lowercase)
B) __hidden (double underscore)
C) UserVar
D) count2
[Answer:] B
19. Which of the following is true for identifiers in C regarding whitespace?
A) Identifiers may contain whitespace characters.
B) Whitespace is allowed only at the start.
C) Whitespace is not allowed inside identifiers.
D) Tabs are allowed inside identifiers.
[Answer:] C
20. Which of the following identifiers is valid and does not conflict with C keywords?
A) switch
B) Switch
C) switch_case
D) case
[Answer:] C
21. The identifier longlong in C is:
A) A valid identifier and not the same as the long long type.
B) A keyword representing a data type.
C) Illegal because it repeats long.
D) Reserved by the compiler.
[Answer:] A
22. Which identifier declaration violates the naming rules?
A) int _2nd;
B) int second_2;
C) int _;
D) int 2nd;
[Answer:] D
23. Which of these choices correctly distinguishes identifiers and keywords?
A) Keywords can be redefined as identifiers; identifiers cannot be keywords.
B) Identifiers are user-defined names; keywords are reserved words with predefined meaning.
C) Identifiers are always function names; keywords are always variable names.
D) There is no difference.
[Answer:] B
24. Which of the following can be an identifier?
A) #define
B) __LINE__
C) my_var
D) /*comment*/
[Answer:] C
25. Why is __STDC__ typically not a good choice for a user-defined identifier?
A) It is a reserved macro used by the implementation.
B) It is too long.
C) Underscores are not allowed.
D) It starts with a digit.
[Answer:] A
26. Which rule is true about identifiers and functions?
A) Function names are not identifiers.
B) Function names follow the same naming rules as variable identifiers.
C) Functions have no name in C.
D) Function names may contain spaces.
[Answer:] B
27. Which identifier is valid and conventional for a static file-scope variable?
A) __filecounter
B) file_counter
C) FileCounter
D) int
[Answer:] B
28. Which of these identifiers is invalid because it matches a C keyword exactly?
A) while_loop
B) while
C) WHILE
D) __while
[Answer:] B
29. Which of the following statements is true about identifiers and the preprocessor?
A) Macro names are identifiers used by the preprocessor.
B) Preprocessor directives are not related to identifiers.
C) Identifiers cannot be used in macros.
D) Macro names must be numbers.
[Answer:] A
30. Which of the following identifiers is legal but not recommended because it may clash with library identifiers?
A) __init_lib
B) userCount
C) total
D) x1
[Answer:] A
31. Which of the following identifiers would be treated as different from count by the C compiler?
A) Count
B) count
C) count (with a trailing space)
D) count\0
[Answer:] A
32. Which identifier demonstrates use of Hungarian-style naming convention (type prefix)?
A) iCount
B) count
C) CountNumber
D) _count
[Answer:] A
33. Which of the following is true about identifiers used as labels for goto?
A) Labels are not identifiers.
B) Labels share the same namespace as variables.
C) Labels are identifiers but occupy a separate namespace from variables and functions.
D) Labels must start with an uppercase letter.
[Answer:] C
34. Which of the following is true about external linkage and identifiers?
A) static gives an identifier external linkage.
B) An identifier with external linkage can be referred to from other translation units.
C) Identifiers with external linkage are visible only within the block where they are declared.
D) External linkage is the same as automatic storage.
[Answer:] B
35. Which of the following identifier names suggests an identifier with file scope?
A) localCounter declared inside main()
B) global_count declared outside all functions
C) temp declared inside a loop
D) i declared as a loop counter
[Answer:] B
36. Which of the following identifiers is allowed but may be flagged by static analysis for style?
A) a
B) sum_total
C) customerBalance
D) order_count
[Answer:] A
37. What is the namespace of tag names used in struct and union declarations in C?
A) They share the same namespace as variables.
B) tag names occupy their own namespace separate from ordinary identifiers.
C) They are keywords.
D) They must be prefixed with tag_.
[Answer:] B
38. Which identifier cannot be redefined as a macro name safely?
A) MAX
B) main
C) myVar
D) temp
[Answer:] B
39. Which of the following describes an identifier with internal linkage?
A) It is visible across multiple source files.
B) It is visible only within the translation unit where it is defined.
C) It is visible only inside a function block.
D) It is visible to the operating system.
[Answer:] B
40. If two different translation units define the same non-static global identifier, what typically happens?
A) They are merged automatically.
B) The linker may report a multiple-definition error.
C) The compiler renames one of them.
D) The runtime chooses one arbitrarily.
[Answer:] B
41. Which identifier is a legal variable name but often discouraged because it is too short and unclear?
A) total_items
B) x
C) numStudents
D) student_count
[Answer:] B
42. Which of the following identifiers is valid and uses underscore convention for private members in some codebases?
A) _private_value
B) private-value
C) private value
D) 1_private
[Answer:] A
43. Which of these will be treated as different identifiers by the compiler?
A) temp and temp
B) temp and Temp
C) temp and temp (trailing space)
D) temp and temp\n
[Answer:] B
44. Which of the following identifiers is invalid because it contains an illegal character?
A) value@home
B) value_home
C) val123
D) _value
[Answer:] A
45. In C, what does the identifier main represent?
A) It is a keyword.
B) It is a user-defined variable.
C) It is a special function name where program execution begins.
D) It is a macro.
[Answer:] C
46. Which identifier name would be best for a macro constant representing array size?
A) arraySize
B) ARRAY_SIZE
C) ArraySize
D) array_size
[Answer:] B
47. Which statement about identifiers and storage classes is correct?
A) Storage class specifiers are part of the identifier name.
B) Storage class affects the lifetime and linkage but not the syntax of the identifier itself.
C) You must include the storage class in the identifier.
D) Identifiers automatically get external storage.
[Answer:] B
48. Which identifier would be considered invalid by the lexical rules of C?
A) α_beta (using a Greek alpha character) — assuming implementation does not support it
B) alpha_beta
C) alphaBeta
D) _alphaBeta
[Answer:] A
49. Which identifier will be different from __x according to the C standard’s reservation rules?
A) __x
B) _x
C) x__
D) __X
[Answer:] B
50. Which of the following is true about identifiers used in multiple scopes (shadowing)?
A) Shadowing is impossible in C.
B) A nested block may declare an identifier with the same name as an outer block, which hides the outer identifier inside the inner block.
C) Declaring the same name in an inner block changes the outer identifier globally.
D) Shadowing causes a linker error.
[Answer:] B
51. Which choice is true for an identifier declared with static at file scope?
A) It has external linkage.
B) It has internal linkage — visible only within that translation unit.
C) It has automatic storage duration.
D) It is visible to the linker across files.
[Answer:] B
52. Which identifier is valid for a typedef name?
A) int
B) Float32
C) struct
D) extern
[Answer:] B
53. Which of the following identifiers is invalid because it exactly matches a universal-character-name macro predefined by the implementation?
A) __FILE__
B) file
C) File
D) _FILE_
[Answer:] A
54. Which of the following is true about identifiers in different namespaces in C?
A) Tag names (struct/union/enum) share the same namespace as variables.
B) Function names, variable names, and tag names all share a single global namespace.
C) C has separate namespaces: ordinary identifiers, labels, tags, and members can be separate.
D) There is no namespace concept in C.
[Answer:] C
55. Which of the following is an invalid identifier due to starting with a punctuation character?
A) #define
B) .hidden
C) value1
D) __hidden
[Answer:] B
56. Which identifier would correctly declare a pointer variable following common naming conventions?
A) ptr_value
B) value*
C) *pointer
D) pointer-addr
[Answer:] A
57. Which of the following is true about identifiers used in function prototypes?
A) Parameter names are mandatory in prototypes.
B) Parameter names in prototypes are optional and do not affect linkage.
C) Identifiers cannot be used in prototypes.
D) Parameter names in prototypes determine external names.
[Answer:] B
58. Which identifier is invalid because it uses a hyphen?
A) user-name
B) user_name
C) username
D) userName
[Answer:] A
59. Which of the following is true when a macro and a variable share the same identifier name?
A) The macro replaces occurrences before compilation; it may conflict with variable usage.
B) Macros and variables never conflict.
C) The compiler automatically renames the variable.
D) The linker resolves the conflict.
[Answer:] A
60. Which of the following identifiers is recommended for a local loop counter?
A) i
B) indexOfStudentsLongNameArray
C) globalIndex
D) main
[Answer:] A
61. Which identifier is invalid in C because it contains an exclamation mark?
A) is_valid!
B) is_valid
C) IsValid
D) isvalid1
[Answer:] A
62. Which of the following best describes the relationship between identifiers and types?
A) Identifier names include type information that the compiler uses at runtime.
B) Identifiers are independent names; types are associated with them in declarations.
C) Identifiers must encode the type in their name.
D) Identifiers are a kind of type.
[Answer:] B
63. Which identifier use-case is not allowed by the C language?
A) Using the same name for a variable and a function in the same scope.
B) Using the same name for a struct tag and a variable in the same scope (allowed, different namespace).
C) Using the same name for two variables in the same block (not allowed).
D) Using the same name for labels and variables (allowed; different namespace).
[Answer:] A
64. Which identifier is valid as an enumerator constant name?
A) enum
B) MAX_VALUE
C) 1ST
D) #VALUE
[Answer:] B
65. Which statement is correct about identifier characters after the first character?
A) They may include letters, digits, and underscores.
B) They can include spaces.
C) They cannot include digits.
D) They must be uppercase.
[Answer:] A
66. Which identifier is invalid because it is a C keyword?
A) signed
B) sign
C) SIGN
D) sign_
[Answer:] A
67. Which of the following identifiers is allowed but might clash with POSIX reserved names in some systems?
A) _POSIX_VERSION
B) POSIX_VERSION
C) posix
D) posixVersion
[Answer:] A
68. Which identifier is valid as a struct member name?
A) int
B) member_count
C) struct
D) typedef
[Answer:] B
69. Which of the following naming practices helps avoid collisions in large projects?
A) Using very short single-letter identifiers everywhere.
B) Using project-specific prefixes (e.g., proj_) for global identifiers.
C) Using double underscores for user identifiers.
D) Using reserved keywords as names.
[Answer:] B
70. Which identifier is a valid typedef name?
A) typedef
B) MY_TYPE
C) if
D) case
[Answer:] B
71. Which identifier is invalid in C because it contains a dollar sign (assuming standard portable C)?
A) price$
B) price
C) total_price
D) p
[Answer:] A
72. Which of these is true about identifiers and linkage?
A) Identifiers never have linkage.
B) Only functions and objects (variables) may have linkage; labels do not.
C) Labels have external linkage.
D) Typedef names have external linkage.
[Answer:] B
73. Which of these is the correct reason auto cannot be used as an identifier in C?
A) auto is not a valid identifier because it contains a vowel.
B) auto is a keyword (storage-class specifier) reserved by the language.
C) auto is allowed and commonly used as an identifier.
D) auto is only reserved in C++.
[Answer:] B
74. Which of the following statements is correct about identifier uniqueness and linkage?
A) Two different translation units may define the same non-static global identifier and the program will always link successfully.
B) Two different translation units may define the same non-static global identifier only if they have compatible types and the One Definition Rule is observed (linker may still error on duplicate definitions).
C) Identical global names across translation units are always allowed and create separate entities.
D) Identifiers cannot be used across translation units.
[Answer:] B
75. Which of the following is true about identifier __func__ in C99 and later?
A) It is a keyword.
B) It is a predefined identifier-like macro that expands to the current function name.
C) It must be defined by the user.
D) It is reserved for external linkage functions only.
[Answer:] B
76. Which of the following identifier forms is preferred for macro names to make them stand out?
A) MAXSIZE
B) MaxSize
C) max_size
D) maxsize
[Answer:] A
77. Which identifier declaration uses a reserved prefix and is therefore ill-advised for user code?
A) int __private_count;
B) int user_count;
C) int total;
D) int data_count;
[Answer:] A
78. Which identifier is valid and demonstrates camelCase naming?
A) numberOfItems
B) number_of_items
C) NUMBER_OF_ITEMS
D) numberofitems
[Answer:] A
79. Which statement about identifiers and the linker is correct?
A) The linker cares only about types, not about identifier names.
B) The linker resolves external references by matching identifier names.
C) The linker ignores identifier names and matches by memory addresses.
D) The linker can rename identifiers arbitrarily.
[Answer:] B
80. Which identifier is valid but should not be used as a filename macro because it conflicts with standard macros?
A) __DATE__
B) MY_DATE
C) BUILD_DATE
D) DATEINFO
[Answer:] A
81. Which of the following identifiers would be treated as the same by the compiler in C?
A) count and count\0
B) count and Count
C) Two case-identical names total and total in same scope
D) count and count (with trailing space)
[Answer:] C
82. Which identifier form is commonly used for private file-scope variables to reduce collision risk?
A) static int file_counter; with name file_counter
B) int file_counter; (non-static)
C) extern int file_counter;
D) static int __file_counter; (double underscore)
[Answer:] A
83. Which of these will NOT be a valid identifier in conforming C source?
A) _ (single underscore)
B) __ (double underscore)
C) ___name
D) 123abc
[Answer:] D
84. Which of the following explains why identifiers that match library names are risky?
A) They can cause name collisions at link time or when macros are involved.
B) They slow down the program.
C) They make the program portable.
D) They are optimized away by the compiler.
[Answer:] A
85. Which identifier is valid as a member of a union?
A) union
B) value
C) void
D) extern
[Answer:] B
86. Which identifier naming convention is typically used for constants to signal immutability?
A) totalCount
B) TOTAL_COUNT
C) total_count
D) TotalCount
[Answer:] B
87. Which of the following is true about identifiers and preprocessing concatenation (##)?
A) The ## operator can combine tokens to form new identifiers during macro expansion.
B) The ## operator turns identifiers into strings.
C) The ## operator deletes identifiers.
D) ## is unrelated to identifiers.
[Answer:] A
88. Which identifier would be invalid in strict portable C because it contains non-portable character $?
A) price$
B) price_value
C) p123
D) price
[Answer:] A
89. Which of these is true about using digits inside identifiers?
A) Digits cannot appear anywhere in an identifier.
B) Digits may appear after the first character.
C) Identifiers may consist only of digits.
D) Identifiers must include at least one digit.
[Answer:] B
90. Which identifier is invalid due to using a C keyword with different capitalization that is still reserved?
A) INT
B) int
C) InT
D) iNt
[Answer:] B
91. Which of the following identifiers is valid in both C and common compilers but might be rejected by some strict tools due to nonstandard characters?
A) naïve_count (contains ï)
B) naive_count
C) naiveCount
D) naive_count1
[Answer:] A
92. Which of the following is true about labels as identifiers?
A) Labels must appear only at function scope and are case-sensitive.
B) Labels can be used across functions.
C) Labels are part of the same namespace as variables.
D) Labels must start with underscore.
[Answer:] A
93. Which identifier is valid but poor practice because it uses a leading underscore followed by uppercase (which is reserved in some contexts)?
A) _Temp
B) temp_
C) temp
D) Ttemp
[Answer:] A
94. Which of the following identifiers is invalid if declared twice in the same scope with different types?
A) int x; float x; — redeclaration with incompatible types
B) int x; int x; — identical declarations
C) Both declarations in separate nested blocks (one shadows the other)
D) static int x; and static int x; in the same file
[Answer:] A
95. Which identifier usage is allowed by C’s grammar?
A) Declaring a struct tag and later declaring a variable with the same name as the tag.
B) Declaring two functions with identical signatures in the same file.
C) Declaring two global variables with same name in same translation unit without extern.
D) Declaring an identifier with spaces.
[Answer:] A
96. Which of these is true about using uppercase letters in identifiers?
A) Uppercase letters are illegal.
B) Uppercase letters are allowed and often used for macros or constants.
C) Uppercase letters change the meaning of the identifier to a keyword.
D) Uppercase letters must be avoided.
[Answer:] B
97. Which identifier name is most suitable for a structure tag?
A) struct student with tag name student
B) struct int
C) struct 123
D) struct if
[Answer:] A
98. Which identifier is valid and shows snake_case naming style?
A) student_roll_number
B) StudentRollNumber
C) STUDENTROLLNUMBER
D) studentRollNumber
[Answer:] A
99. Which statement best describes reserved identifiers in C?
A) Identifiers starting with an underscore followed by an uppercase letter or another underscore are reserved for the implementation.
B) Any identifier starting with a letter is reserved.
C) Identifiers containing digits are reserved.
D) Identifiers ending with underscore are reserved.
[Answer:] A
100. Which of the following is the correct practice for avoiding identifier collisions across large projects?
A) Use short single-letter global identifiers.
B) Use project or module prefixes for global identifiers and public APIs.
C) Use leading double underscores for your public APIs.
D) Reuse names from the standard library.
[Answer:] B
