Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+20 votes
asked in CSC211_Winter2018 by (1 point)

1 Answer

+8 votes

The "(int)" casts the result of the equation to an integer value. So, the variable result is an integer however the expression contains all doubles. The "(int)" takes the answer to the expression and turns it into an int that can be stored in result.

answered by (1 point)
+5

It's important to note for this that when the double is cast into an integer it is simply truncated and not rounded. That means that everything after the decimal is just cut off unlike rounding.

...