Computer Science, asked by hemanth5A7, 4 months ago

which combination of the integer variables a,b and c makes the variable m get the value 4 in the following expression ?
m=(a>b)? ((a>c)?a:c):((b>c)?b:c)

Answers

Answered by poojan
1

a) a=3, b=4, c=2

It is a GATE bit that needs options to verify.

Given data:

Expression:  m = ( a > b ) ? ( ( a > c ) ? a : c ) : ( ( b > c ) ? b : c)

a) a=3,b=4,c=2

b) a=6,b=5,c=3

c) a=6,b=3,c=5

d) a=5,b=4,c=5

To find:

On which combination, the evaluation of the given expression result in 4 as an output.

Solution:

Condition? a:b -> If the condition results true, x will be executed, else, y.

As the complete expression contain just the conditions and the respective variables, we can eliminate options b and c, as they don't have a value 4 in any of the variables.

So, Options a and d are left.

(a>b)? ((a>c)?a:c):((b>c)?b:c)

Option A: a=3,b=4,c=2

(3>4)? ((a>c)?a:c) : ((b>c)?b:c)    

3>4 is a False condition. So, we will consider else part

(3>4)? ((a>c)?a:c) : ((b>c)?b:c)  

→ ((b>c)?b:c) = (4>2)?b:c      4>2 is true, so b will be printed. b=4

The value of b is 4. So, the given expression results in 4 as output for the values a=3,b=4,c=2

Similarly,

Option D: a=5,b=4,c=5

(5>4)? ((a>c)?a:c) : ((b>c)?b:c)        5>4 is True. So, go to if.

((a>c)?a:c) = (5>5)      

There is no 4 in a or c to result 4 as output here. So, eliminate it.

Therefore, a) a=3,b=4,c=2  is the answer.

Learn more:

1. Tools > ________ deals with equations with multiple unknown variables.

brainly.in/question/20886057

2. Ch+=2 is equivalent to​

brainly.in/question/21331324

Similar questions