Question:

What is the value of the following C statement when the value of the variable $ x = 600 $? $$ \text{tax} = ( x<500 ) ? ( ( x>400 ) ? x*20 : x*10 ) : ( x<700 ) ? x*25 : x*30; $$

Show Hint

When using ternary operators, make sure to evaluate the conditions from the inside out to determine the correct result.
Updated On: May 3, 2025
  • 15000
  • 6000
  • 12000
  • 18000
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

The expression uses the ternary (conditional) operator to compute the value of \( \text{tax} \). Given that \( x = 600 \):
- Since \( x<700 \) is true, the second ternary condition evaluates, and \( x \times 25 \) is computed.
- \( 600 \times 25 = 15000 \).
Thus, the value of the expression is \( 15000 \).
Was this answer helpful?
0
0

Top Questions on Programming in C

View More Questions