recategorized by
480 views
1 votes
1 votes
Let "if x then y else z" denote the expression and this expression can be represented ad "?xyz" using ternary prefix operator

the prefix operator for the following expression is

 

If a then if c-d then a+c else a*c else a+b

 

A) ?-acd+ac?+ab+ac

B) ?a?-cd+ac*ac+ab

C)?a-cd?+ac*ac+ab

D )none
recategorized by

1 Answer

2 votes
2 votes

given that If a then if c-d then a+c else a*c else a+b

parenthesize it ===> If a then if c-d then a+c else a*c else a+b

therefore first solve if c-d then a+c else a*c

given that if x then y else z represented as ?xyz ===> we know that x?yz is ternary operator in INFIX form ==> ?xyz is ternary operator in PREFIX form ==> therefore you have to use here Prefix forms only.

let c-d = x , a+c = y and a*c = z ===> ?(c-d)(a+c)(a*c) but we need to convert x,y and z also in prefix format..

if c-d then a+c else a*c ===> ?(-cd)(+ac)(*ac) ===> ? - c d + a c * a c

 

 If a then if c-d then a+c else a*c else a+b, for solving this, let x = a, y = if c-d then a+c else a*c  and z = a+b ( prefix form of z = + a b )

therefore If a then if c-d then a+c else a*c else a+b  ===> ? a  ? - c d + a c * a c + a b

Related questions

1 votes
1 votes
2 answers
1
0 votes
0 votes
1 answer
2
ukn asked Jan 19, 2017
389 views
0 votes
0 votes
3 answers
3
3 votes
3 votes
5 answers
4
arpit.bagri asked Aug 6, 2023
1,044 views
Why is the output of the below program 36? int main(){ int a = 1; int b = ++a * ++a * ++a; printf("%d", b ); ​​​​ return 0; }