0

# Why 450/500*100 gives zero

In this according to the associativity of operators The division should be performed first as it has left to right associativity and in division the left side i.e 450 is unambiguous and hence the value of the expression should be 90 not 0... https://code.sololearn.com/cxv8c9sgTaMT/?ref=app

1 Answer

+ 5

You are performing integer divison which results in an int, so 450 / 500 = 0 the decimal part is truncated. Try using either 450.0 or 500.0.