Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+20 votes
asked in CSC211_Winter2018 by (8 points)

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 (8 points)
+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.

...