Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers? (A) max = a>b ? a>c?a:c:b>c?b:c (B) B=b ? c=30; (C) a>b : c=30 : c=40; (D) return (a>b)?(a:b) ?a:c:b
Answers
HERE IS UR ANSWER
the correct implementation of nested conditional operation by finding greatest number out of three numbers is max = a>b
The correct implementation of nested conditional operation by finding greatest number out of three numbers is max = a>b ? a>c?a:c:b>c?b:c (Option A).
Explanation: You will be able to understand the execution by the given steps:
Step1: It is a ternary/conditional operator where max? implies the condition. It will get the maximum out of three numbers.
Step2: a>b? a>c? a:c:b>c? b:c, these part consists of true and false since it is nested, we have to prove two conditions.
Step3: a>b ? a> c? will give be solved separately. If a is greater than b then it will return an otherwise b. Similar will happen with a and c where the biggest one out of a and c will be returned and we would be left with either a? c or a? a or b? c.
Step3: a:c:b>c? b:c, this will work similarly where you will be left ith to values.