What will be the value of sum when val= 1000 [3] int val , sum, n=750; sum = n+val > 1750 ? 400 : 200 ; System.out.println(sum);
Answers
Answered by
0
Answer:
Explanation:
When val = 1000, val + 550 = 1550. As 1550 is less than 1700 so condition of ternary operator is true. Variable c is assigned the value of expression 1 which is 200.
When val = 1500, val + 550 = 2050. As 2050 is greater than 1700 so condition of ternary operator is false. Variable c is assigned the value of expression 2 which is 400.
Similar questions