Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q351: What does 'void' return as a token according to the sample scanner output?
- A: 259
- B: 258
- C: 260
- D: 261
View Answer
A
Q352: In the scanner output, what token is associated with the identifier 'main'?
- A: 258
- B: 259
- C: 260
- D: 261
View Answer
A
Q353: The character ',' in Flex rules returns which token?
- A: COMMA
- B: SEMICOLON
- C: ','
- D: SEPARATOR
View Answer
C
Q354: Which keyword among the following is not defined in the sample Flex rules?
- A: auto
- B: new
- C: bool
- D: string
View Answer
D
Q355: The operator '!=' corresponds to which token in Flex rules?
- A: NOTEQ
- B: EQ
- C: NE
- D: EQUAL
View Answer
A
Q356: Which rule will match a hexadecimal number in C++?
- A: 0x[0-9]+
- B: 0[xX][0-9a-fA-F]+{intsuffix}?
- C: #[0-9A-F]+
- D: [HEX]+
View Answer
B
Q357: How many parts are in the typical Flex input file?
- A: One
- B: Two
- C: Three
- D: Four
View Answer
C
Q358: C++ comment starting with '//' is skipped by which function?
- A: skip_comment()
- B: skip_to_newline()
- C: skip_until_eol()
- D: clear_line()
View Answer
C
Q359: The Flex pattern for recognizing string literals involves ______.
- A: \d+
- B: \"{stringtext}\"
- C: [a-zA-Z]+
- D: '{chartext}'
View Answer
B
Q360: Which token is associated with the 'if' keyword in C++ in the Flex rules?
- A: COND
- B: IF
- C: BRANCH
- D: CONTROL
View Answer
B