GATE Computer ScienceHardGATE CS (PYQ pattern)

A compiler generates jumping code by backpatching (each relation gives 'if r goto _' then 'goto _', numbering from 100) for: if (!(a < b) && (c < d || e < f)) x = 1; else x = 2; In the generated code, to which instruction number does the false-branch 'goto' of the test a < b (number 101) jump?

  1. A. 100
  2. B. 104
  3. C. 102
  4. D. 103

Correct answer: C. 102

'!' swaps the lists, so the 'goto' after a<b (101) is now the true exit of !(a<b) and is backpatched to the start of the (c<d || e<f) test, i.e. 102; the 'if a<b goto' at 100 becomes a false exit and goes to the else part.

More Compiler Design questions

Exams that ask this topic