(b) What will be the value of b, c when n1=10, n2=0 given that
int b= (n1 < n2)?n1:n2;
double c={n2!=0)?(n1/n2):(n1*2);
Answers
Answered by
22
Answer:
Ternary Operator:
Syntax:
variable x=(expression) ? value if true: value if false
The true statement is executed if the Expression is true else it will execute false statement
10<0 Condition is false
so the n2 value 0 executes
Answer:
0
0!=0 Condition is false
so it goes to the (value if false) statement
n1*2 = 20.0 here it is double
Answer:
20.0
Similar questions