GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Using the standard backpatching scheme (each relational test yields 'if a<b goto _' followed by 'goto _', with no fall-through optimisation and instruction numbers starting at 100), how many three-address instructions are generated for: while (a < b && c < d || e < f) { if (x < y) p = 1; else q = 2; }? The loop's exit is the next instruction after the final goto.
- A. 11
- B. 13
- C. 9
- D. 12
Correct answer: D. 12
Three relops give 6 jumps; the if-else gives 2 (test) + 1 + 1 (skip goto) + 1 = 5; the loop adds a closing 'goto 100'; total 12.
More Compiler Design questions
- For S → a A | A b; A → c | ε (augmented), how many non-blank ACTION entries does the initial state I0 have in the SLR(1) table, and in the…
- For S → a S | a S b S | c (augmented), how many states does the canonical LR(1) automaton have, and how many ACTION cells of the canonical…
- For G: S → A | B; A → a A b | ε; B → a B b b | ε, which of these statements are true? I. Exactly two cells of the LL(1) table, M[S, a] and…
- The grammar S → i S | i S e S | a is ambiguous. How many distinct parse trees does the string "i i i a e a e a" have?
- int A(int m, int n) { if (m == 0) return n + 1; if (n == 0) return A(m - 1, 1); return A(m - 1, A(m, n - 1)); } Each activation record…
- For S → id | id [ E ] | id ( E ); E → id (augmented with S′ → S), how many states do the LR(0) and the canonical LR(1) automata have?