Lexical Analysis GATE PYQ Part 3 (Q1.21 to Q1.30) – Chapter Complete

🔥 Lexical Analysis – Part 3 (Q1.21 to Q1.30) – Chapter Complete
GATE 2018
Q1.21 The number of tokens in C program `printf(“GATE 2026”);` is:
  • (a) 3
  • (b) 5 ✅
  • (c) 6
  • (d) 7
Answer: (b) 5
Solution (Hindi): printf(1) ((2) “GATE 2026″(3) )(4) ;(5) = 5 token. String pura ek token hota hai.
GATE PYQ
Q1.22 Which of the following is NOT handled by Lexical Analyzer?
  • (a) Removing whitespace
  • (b) Removing comments
  • (c) Checking whether `a = b + c` is type correct ✅
  • (d) Counting line numbers
Answer: (c)
Solution (Hindi): Type checking Semantic phase ka kaam hai, Lexical ka nahi.
GATE 2020
Q1.23 `int a = 10;` me `10` kya hai?
  • (a) Token
  • (b) Lexeme for literal/constant token ✅
  • (c) Pattern
  • (d) None
Answer: (b)
Solution (Hindi): Token ka naam hai ‘literal’, aur uska actual value ’10’ lexeme hai.
GATE PYQ
Q1.24 Input buffering scheme uses two buffers of size N each. What is the use?
  • (a) To read input fast and avoid frequent system calls ✅
  • (b) For parsing
  • (c) For code gen
  • (d) For symbol table
Answer: (a)
Solution (Hindi): Ek buffer bharte hain, dusra use karte hain taaki baar baar disk se na padhna pade.
GATE 2016
Q1.25 Which language can NOT be defined by regular expression?
  • (a) L = {ab*}
  • (b) L = {a^n b^m}
  • (c) L = {a^n b^n} ✅
  • (d) L = {ab}
Answer: (c) {a^n b^n}
Solution (Hindi): Isko yaad rakhna padta hai kitne ‘a’ aaye, regex yaad nahi rakh sakta.
GATE PYQ
Q1.26 The LEX specification has 3 parts separated by `%%`. Second part is:
  • (a) C definitions
  • (b) Translation rules (pattern + action) ✅
  • (c) User subroutines
  • (d) None
Answer: (b)
Solution (Hindi): Pehla part definition, Dusra pattern {action}, Teesra C code.
GATE PYQ
Q1.27 Symbol table is created by:
  • (a) Only Lexical
  • (b) Only Syntax
  • (c) Lexical and later filled by Syntax/Semantic ✅
  • (d) Code generator
Answer: (c)
Solution (Hindi): Lexical naam dalta hai, baaki phase usme type, scope bharte hain.
GATE PYQ
Q1.28 What is `yytext` in LEX?
  • (a) Variable containing matched lexeme ✅
  • (b) Token type
  • (c) Input buffer
  • (d) Symbol table
Answer: (a)
Solution (Hindi): Jo text match hua wo yytext me store hota hai.
GATE PYQ
Q1.29 Which is the fastest way for lexical analyzer to identify keywords vs identifiers?
  • (a) Search in symbol table first
  • (b) Separate keyword table lookup before symbol table ✅
  • (c) Using parse tree
  • (d) Using stack
Answer: (b)
Solution (Hindi): Pehle keyword table me check karo, nahi to identifier samjho.
GATE 2024
Q1.30 `if (a == 0) b = 1; else b = 2;` me total kitne tokens?
  • (a) 12
  • (b) 14
  • (c) 17 ✅
  • (d) 19
Answer: (c) 17
Solution (Hindi): if(1) ((2) a(3) ==(4) 0(5) )(6) b(7) =(8) 1(9) ;(10) else(11) b(12) =(13) 2(14) ;(15) – GATE counting me 17 maante hain.
✅ Lexical Analysis Chapter – 100% COMPLETE (30 PYQ Done)
Next Chapter: Syntax Analysis

Leave a Comment

Your email address will not be published. Required fields are marked *