Gate2017 cs Q52

0. Consider the following grammar:
stmt → if exp r then else exp r ;stmt 0
exp r → termrelop term term
term → id | number
if → a | b | c
number → [0...9]
where relop is a relational operate (e.g <, >,...) ---O refers to the empty statement, and if, then, else are terminals.
Consider a program P following the above grammar containing ten if terminals. The number of control flows paths in P is _____. For example the program
if e1 then e2 else e3
has 2 controls flow paths e1→ e2 and e1 → e3

  • Option : C
  • Explanation :
    For 2 “if statements”, 22 = 4 control flow paths are possible:

    So for 10 “If statements”, control flow paths will be there.
Cancel reply

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


Cancel reply

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