Deprecated: Implicit conversion from float-string "1636101326.594" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1636101326.594" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1636101326.594" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1636101326.594" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1636101326.594" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1669353359.480" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1669353359.480" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1669353359.480" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1669353359.480" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1669353359.480" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1656922632.556" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1656922632.556" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1656922632.556" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1656922632.556" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1656922632.556" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Compiler Design: GATE CSE 1989 | Question: 4-v
edited by
1,864 views
5 votes
5 votes

Is the following code template for the if-then-else statement correct? if not, correct it.

  • $\text{if} \text{ expression then statement } 1$
    $\text{else statement }2$

Template:

Code for expression

  • (*result in $E, E > O$ indicates true *)
  • Branch on $E > O$ to $L1$
  • Code for statement $1$
  • $L1$: Code for statement $2$
edited by

2 Answers

Best answer
18 votes
18 votes

The given template is wrong. The following should be correct:

Code for Expression

  • Branch on $E>0$ to $L$
  • Code for segment $2$
  • Branch to $L1$
  • $L$: Code for statement $1$
  • $L1$:
edited by
0 votes
0 votes

What is expected from the code:

“if expression is true execute statement 1, else execute statement 2.”

What given code is doing:

“if expression (E > 0) is true execute statement 2, else execute statement 1.”

Modified Template:

Code for expression

  • (*result in E, E>O indicates true *)
  • Branch on E>O to L1
  • Code for statement 2
  • L1: Code for statement 1

Related questions

739
views
1 answers
1 votes
makhdoom ghaya asked Nov 30, 2016
739 views
Consider the definition of macro $B,$ nested within the definition of a macro $A.$ Can a call to macro $B$ also appear within macro $A?$ If not, why not? If yes, explain ...
6.6k
views
2 answers
43 votes
makhdoom ghaya asked Nov 27, 2016
6,585 views
The number of possible commutative binary operations that can be defined on a set of $n$ elements (for a given $n$) is ___________.
735
views
1 answers
1 votes
makhdoom ghaya asked Dec 5, 2016
735 views
Consider the following grammar for variable declarations:<vardecl $\rightarrow$ <vardecl><idlist : <type>;<vardecl $\rightarrow \in$<idlist $\rightarrow$ <idlist>, id<idl...
1.3k
views
1 answers
3 votes
makhdoom ghaya asked Dec 5, 2016
1,283 views
Will recursion work correctly in a language with static allocation of all variables? Explain.