Tokens in C Programming MCQ Questions and Answers
1. Which of the following is not a token in C?
A) identifier
B) whitespace
C) constant
D) operator
[Answer: B]
2. The C token type that represents reserved words like int, return, for is called:
A) identifier
B) keyword
C) literal
D) preprocessor
[Answer: B]
3. Which of the following is a valid identifier in C?
A) 2ndValue
B) _count23
C) int
D) #name
[Answer: B]
4. Which token type does the sequence “Hello, world!” belong to?
A) character constant
B) string literal
C) identifier
D) numeric constant
[Answer: B]
5. Which rule is correct for C identifiers?
A) Must start with a digit
B) Can contain spaces
C) Case-insensitive
D) May start with underscore or letter
[Answer: D]
6. The token ++ in C is classified as:
A) punctuation
B) unary operator token
C) keyword
D) literal
[Answer: B]
7. Which of these is a valid integer constant token in C?
A) 09
B) 0x1F
C) 1.0e
D) ‘a’
[Answer: B]
8. What is the token type of /* comment */ after preprocessing?
A) comment token (retained)
B) operator token
C) comment is removed — not a token for compiler
D) string literal
[Answer: C]
9. Which of the following is an example of a punctuator token?
A) +
B) &&
C) ;
D) sizeof
[Answer: C]
10. Multi-character operators such as <<= are recognized by the lexer using which principle?
A) leftmost-longest (maximal munch)
B) always pick single character
C) alphabetical order
D) user-defined rule
[Answer: A]
11. Which token category includes 3.14?
A) integer constant
B) floating constant
C) character constant
D) string literal
[Answer: B]
12. The token typedef is a:
A) macro
B) keyword
C) identifier
D) operator
[Answer: B]
13. Which of the following is not a valid identifier in standard C?
A) main
B) _temp
C) var_name
D) for
[Answer: D]
14. Which of these is not considered an operator token?
A) +=
B) ->
C) #include
D) *
[Answer: C]
15. Character constants like ‘A’ are tokens of type:
A) character literal
B) string literal
C) identifier
D) integer constant
[Answer: A]
16. Which of the following statements about keywords is true?
A) Keywords can be redefined by the programmer
B) Keywords are part of the token set and cannot be used as identifiers
C) Keywords are case-insensitive
D) Keywords are only used in macros
[Answer: B]
17. Which token type does 0b1010 represent in C (C11/C23 context)?
A) invalid token in standard C prior to extensions
B) octal constant
C) hexadecimal constant
D) binary constant (standard C supports this)
[Answer: A]
18. In tokenization, what does the lexer do with whitespace?
A) Converts whitespace into identifier tokens
B) Treats whitespace as significant tokens
C) Generally acts as a delimiter and is discarded
D) Converts whitespace into operator tokens
[Answer: C]
19. Which of the following is a valid floating constant in C?
A) 4f
B) 6.02e23
C) .e10
D) 12e
[Answer: B]
20. The token #define is handled by:
A) the C lexical analyzer as a keyword token
B) the preprocessor — not the regular token stream
C) the linker
D) the runtime environment
[Answer: B]
21. Which token class does && belong to?
A) arithmetic operator
B) logical operator token
C) punctuator token
D) keyword
[Answer: B]
22. Which of the following is a valid octal constant token in C?
A) 089
B) 077
C) 8
D) 0x77
[Answer: B]
23. The sequence /*/ inside a comment:
A) ends the comment
B) is part of comment content until */ terminator
C) causes a compile-time error immediately
D) becomes a token outside comment
[Answer: B]
24. Which of these tokens represent a relational operator?
A) =
B) ==
C) &
D) ++
[Answer: B]
25. Which token type is NULL usually considered in C?
A) keyword
B) macro or identifier (implementation-defined)
C) operator
D) numeric literal always
[Answer: B]
26. A token that represents names introduced by the programmer (variables, functions) is called:
A) identifier
B) keyword
C) constant
D) operator
[Answer: A]
27. Which of the following is NOT a valid form of a numeric constant token?
A) hexadecimal literal (0xFF)
B) binary literal (0b10) in standard C89/C99 without extensions
C) decimal integer (100)
D) floating literal (1.5f)
[Answer: B]
28. Which of the following sequences will be tokenized as two tokens – and – (not –)?
A) a–
B) a – -b
C) –a
D) b– ;
[Answer: B]
29. Which token represents the end of a statement?
A) :
B) ;
C) ,
D) .
[Answer: B]
30. Which of the following is true about string literals in C?
A) Adjacent string literals are concatenated by the compiler at compile time
B) Adjacent string literals are separate arrays at runtime
C) String literals cannot contain escape sequences
D) String literals are tokens that evaluate to integers
[Answer: A]
31. Which token type does the symbol , belong to?
A) operator
B) punctuator (comma operator/token)
C) keyword
D) identifier
[Answer: B]
32. Which token is used to access a member of a structure through a pointer?
A) .
B) ->
C) ::
D) %
[Answer: B]
33. Which of the following is an example of a universal character name used in identifiers (C11)?
A) \u00E9
B) \u00E9
C) /u00E9
D) \U00E9 (invalid)
[Answer: A]
34. The token sizeof is classified as:
A) keyword / operator
B) macro
C) identifier
D) punctuator
[Answer: A]
35. Which of the following is a valid escape sequence inside a character constant?
A) ‘\q’
B) ‘\n’
C) ‘\z’
D) ‘\y’
[Answer: B]
36. Which of the following will the tokenizer consider a single token?
A) ! =
B) !=
C) ! ==
D) ! = =
[Answer: B]
37. Which of these is NOT part of C tokens category?
A) keywords
B) comments (after preprocessing)
C) constants
D) operators
[Answer: B]
38. Which token class does 0 (zero) fall into?
A) float constant
B) integer constant
C) character constant
D) identifier
[Answer: B]
39. Which preprocessor construct is recognized before tokenization?
A) function calls
B) macros (#define)
C) variable declarations
D) pointer operators
[Answer: B]
40. Which of these identifiers is reserved by the implementation and should be avoided in user code?
A) names starting with underscore followed by uppercase letter
B) names starting with lowercase letter
C) names starting with letter and digits
D) names containing underscore anywhere
[Answer: A]
41. Which of these is a valid hexadecimal floating constant in C99 and later?
A) 0x1.8p3
B) 0xG1.2
C) 0x1.8e3 (invalid exponent syntax)
D) 1.8p3
[Answer: A]
42. Which of the following is true about tokens and comments?
A) Comments are tokens passed to the parser
B) Comments are removed by preprocessor and not part of token stream for compilation
C) Comments are treated as string literals
D) Comments are compiled into object code
[Answer: B]
43. Which token in C is used to define a macro argument list?
A) %
B) () parentheses after macro name
C) {} braces after macro name
D) [] brackets after macro name
[Answer: B]
44. Which of the following is a valid wide string literal token?
A) L”abc”
B) W”abc”
C) “Labc”
D) \L”abc”
[Answer: A]
45. Which of these is a valid translation-phase restriction for tokens?
A) Trigraphs are ignored in C11
B) Character sets other than ASCII are forbidden
C) Adjacent tokens may produce a different token (token concatenation) via preprocessor ##
D) Preprocessor tokens are identical to lexical tokens with no special handling
[Answer: C]
46. The # operator in preprocessor macros is classified as:
A) token-pasting operator
B) stringizing operator
C) arithmetic operator
D) bitwise operator
[Answer: B]
47. Which token type does 0x1A belong to?
A) octal constant
B) decimal constant
C) hexadecimal integer constant
D) floating point constant
[Answer: C]
48. Which of the following is NOT a valid way to write a character constant?
A) ‘a’
B) ‘\n’
C) ‘ab’
D) ‘\x41’
[Answer: C]
49. Which token does the C lexical analyzer produce from >>=?
A) ‘>’ ‘>’ ‘=’ (three tokens)
B) ‘>>=’ (single token)
C) ‘>’ ‘>>=’
D) ‘>>’ ‘=’
[Answer: B]
50. Which of these is true about identifiers beginning with underscore?
A) They’re always illegal.
B) They are reserved in some contexts by the implementation.
C) They have special type semantics.
D) They are treated as keywords.
[Answer: B]
51. In C, which token type is ‘\0’?
A) string literal
B) character constant representing NUL
C) integer literal zero only
D) operator
[Answer: B]
52. Which of these is considered an arithmetic operator token?
A) &&
B) %
C) ->
D) sizeof
[Answer: B]
53. The token extern is:
A) a storage-class specifier keyword token
B) an identifier
C) an operator
D) a macro
[Answer: A]
54. Which of the following is a valid universal-character name in an identifier?
A) \u0041 (represents ‘A’)
B) u0041
C) /u0041
D) \u0041 (two backslashes)
[Answer: A]
55. Which of these tokens cannot be split by whitespace into two tokens without changing meaning?
A) + + (becomes two + tokens)
B) == (splitting into = = changes meaning)
C) & &
D) : :
[Answer: B]
56. Which of the following is true about numeric constants and suffixes?
A) 10u is an unsigned integer constant token
B) Suffix u can be applied to string literals
C) 3.14L is not allowed as a token
D) Suffixes are parsed by the linker
[Answer: A]
57. Which of the following sequences is tokenized as a single preprocessing token?
A) #define
B) # define (space between)
C) #\ndefine (newline in between)
D) #/*comment*/define
[Answer: A]
58. Which of these is a valid representation of a character constant using octal escape?
A) ‘\123’
B) ‘\9’
C) ‘\89’
D) ‘\999’
[Answer: A]
59. Which of these is a relational operator token?
A) <<=
B) >=
C) &&
D) ++
[Answer: B]
60. Which token type is the dot . when used in obj.member?
A) operator (member access) / punctuator
B) macro
C) escape sequence
D) keyword
[Answer: A]
61. Which of the following is true: 0 and ‘0’ as tokens represent:
A) both integers equal in value
B) 0 is integer 0; ‘0’ is character constant with numeric value 48 in ASCII
C) ‘0’ is invalid token
D) both are string literals
[Answer: B]
62. Which token category contains enum?
A) identifier
B) storage-class specifier
C) keyword (type specifier)
D) constant
[Answer: C]
63. Which of the following is NOT a token produced by the lexer?
A) preprocessor directives (handled before normal tokens)
B) keywords
C) constants
D) operators
[Answer: A]
64. What happens if two tokens combine into one valid longer token during scanning (e.g., + and = to +=)?
A) They remain two tokens always
B) The longest valid token is chosen (maximal munch)
C) The compiler throws an error
D) Tokens are reversed
[Answer: B]
65. Which token would the compiler see from the input sequence 0x1Fp+3?
A) integer constant then identifier p then + then 3
B) invalid token
C) floating-point hexadecimal literal 0x1Fp+3
D) 0x1F p + 3
[Answer: C]
66. In C, which token denotes bitwise AND?
A) &&
B) &
C) and
D) &&&
[Answer: B]
67. In the context of tokens, the -> and . are:
A) both arithmetic operators
B) both member access operators (punctuators)
C) macros
D) string operators
[Answer: B]
68. Which of these tokens cannot begin an identifier?
A) letter
B) underscore
C) digit
D) universal character name representing a letter
[Answer: C]
69. Which of the following is correct about the preprocessor ## operator?
A) It stringizes tokens
B) It concatenates tokens during macro expansion
C) It comments out tokens
D) It is an arithmetic operator
[Answer: B]
70. Which of the following is a valid token for a floating literal with exponent?
A) 1.5e-2
B) 1.5e-
C) 1.5e+
D) 1.5e–2
[Answer: A]
71. Which of the following is a token that represents pointer dereference?
A) &
B) *
C) ->
D) .
[Answer: B]
72. Which token class does break belong to?
A) identifier
B) keyword (jump statement)
C) operator
D) constant
[Answer: B]
73. Which of the following best describes a preprocessing token?
A) The same as a token the parser sees always
B) The unit used by the preprocessor, such as identifiers, numbers, character constants, string literals, punctuators and other sequences
C) Only macros and includes
D) Only comments
[Answer: B]
74. Which token is produced by ‘\\’ in a character constant?
A) invalid escape token
B) representing backslash character as a character constant ‘\”
C) correct escape sequence — character constant for backslash
D) becomes a string literal
[Answer: C]
75. What token types are created when the input contains a/*c*/b (comments removed)?
A) a / * c * / b
B) a b (comment removed acts as delimiter)
C) a/*c*/b as one token
D) error token
[Answer: B]
76. Which token is a storage-class specifier?
A) const
B) auto
C) volatile
D) sizeof
[Answer: B]
77. Which token is reserved and cannot be used as an identifier in C99?
A) register
B) myRegister
C) _register
D) Register
[Answer: A]
78. Which of the following is a valid raw string token in C?
A) R”delim( raw )delim” (C++ style — not standard C)
B) R”raw” (valid in C)
C) uR”raw” (valid in C)
D) \R”raw”
[Answer: A]
79. The token : ? is incorrect because:
A) ? is a ternary operator and : pairs with it, but written as 😕 is invalid token sequence
B) : is always a string literal
C) ? is an operator but : is illegal
D) Both are keywords
[Answer: A]
80. Which token class includes const and volatile?
A) storage-class specifiers
B) type qualifiers
C) function specifiers
D) operators
[Answer: B]
81. Which token is a valid imaginary number literal in C99?
A) 3.0i (not standard C)
B) 3if (invalid)
C) 3.0 (real floating literal)
D) C does not support imaginary suffices in standard C (except via complex type in C99 using macros)
[Answer: D]
82. Which of the following is true about trigraphs and tokens?
A) Trigraphs are expanded before tokenization in translation phase 1/2 (historically)
B) Trigraphs are parsed by the linker
C) Trigraphs create new keywords
D) Trigraphs are not part of the C standard anywhere
[Answer: A]
83. Which token type does 0.1f belong to?
A) integer constant
B) floating constant with f suffix (float)
C) character literal
D) string literal
[Answer: B]
84. Which token sequence is parsed as a single token: ==, ===?
A) both are single tokens in standard C
B) == is a token; === is == and = tokens (so not single)
C) === is the equality operator in C
D) === is tokenized as a trigraph
[Answer: B]
85. Which token is the ternary operator in C?
A) ??
B) ? : (question mark and colon together as ternary operator)
C) 😕
D) ?: (single token)
[Answer: B]
86. Which token is used for modulus operation?
A) %
B) /
C) &
D) ^
[Answer: A]
87. Which token type does ‘\n’ in source code represent?
A) numeric constant
B) character constant with newline escape
C) string literal
D) operator
[Answer: B]
88. Which token best describes the #include <stdio.h> angle-bracket sequence?
A) string literal token
B) header-name preprocessing token distinct from ordinary string literal tokens
C) identifier token
D) operator token
[Answer: B]
89. Which of the following describes extern “C”?
A) valid standard C token sequence
B) C++ linkage specification — not a C token sequence in pure C
C) preprocessor directive
D) operator usage in C
[Answer: B]
90. Which token is a bitwise shift-left operator?
A) <<
B) >>
C) <<<
D) <-
[Answer: A]
91. Which token type does 3uLL represent?
A) float constant
B) signed integer constant
C) unsigned long long integer constant token
D) character constant
[Answer: C]
92. Which of the following is true about token concatenation in macros?
A) ## concatenation occurs during macro replacement to form new tokens
B) ## concatenation converts tokens into comments
C) ## concatenation executes code at runtime
D) ## is an arithmetic operator
[Answer: A]
93. Which token type is volatile?
A) storage-class specifier
B) type qualifier keyword token
C) operator
D) literal
[Answer: B]
94. Which token will result from a<<=2?
A) a << = 2
B) a <<= 2 (compound assignment token)
C) a < < = 2
D) Syntax error at lexical stage
[Answer: B]
95. Which of the following is true about adjacent string literal tokens?
A) “foo” “bar” becomes “foobar” (concatenated)
B) They remain separate at runtime and are accessed via indices
C) Adjacent string tokens cause a syntax error
D) They are concatenated only if separated by a plus sign
[Answer: A]
96. Which token does the ?: operator involve?
A) only ? token
B) both ? and : tokens forming ternary operator
C) ?: single token in C
D) : alone is the ternary operator
[Answer: B]
97. Which of the following is a valid escape for hexadecimal in character constants?
A) ‘\x41’
B) ‘\h41’
C) ‘\z41’
D) ‘\xG1’
[Answer: A]
98. Which of the following best describes inline in C99?
A) an operator
B) a function specifier keyword token (may be a keyword)
C) an identifier usable freely as variable name
D) a macro only
[Answer: B]
99. Which of the following is true about token boundaries?
A) The lexer always splits tokens at semicolons only
B) Token boundaries may depend on longest-match rules and whitespace
C) Whitespace is always required between tokens
D) Comments and whitespace are converted into tokens and passed to parser
[Answer: B]
100. Which of these is true about universal character names in tokens?
A) They can appear in identifiers and character constants using \u or \U notation
B) They are only allowed in string literals
C) They begin with /u in C source
D) They are not part of any C translation phase
[Answer: A]
