GATE Computer ScienceHardGATE CSE · UGC NET
Procedure P(x, y) { x = x + 1; y = x + y; } is called as P(a, a) with a = 3. What is a after the call under call-by-reference, and under call-by-value-result (copy-in both formals, copy-out in left-to-right order x then y)?
- A. 7 and 8
- B. 8 and 3
- C. 8 and 7
- D. 8 and 8
Correct answer: C. 8 and 7
Reference: x and y alias a, so a=4 then a=4+4=8. Value-result: x=3,y=3 → x=4, y=4+3=7; copy-out x then y leaves a = 7.
More Compiler Design questions
- Grammar: S → L = R | R; L → R | id; R → L (augmented with S' → S). How many states do the LR(0) automaton and the canonical LR(1)…
- Grammar: S → a A d | b B d | a B e | b A e; A → c; B → c. How many states does the canonical LR(1) collection contain, how many does…
- For the standard expression grammar E → E + T | T; T → T F | F; F → ( E ) | id (augmented), how many states does the canonical LR(1)…
- For S → C C; C → c C | d (augmented), the canonical LR(1) collection has some states that share an LR(0) core. By how many states does…
- Grammar: S → A a | b A c | d c | b d a; A → d. How many conflicting (state, terminal) entries are there in its SLR(1) table, and how many…
- Consider the grammar S → a S | a S b S | ε. How many distinct parse trees does the string aaabb have?