Jiho Song16,469 Points
what is the answer?
I try to find the answer but couldnt after several attempts. what is the output?
Steven Parker173,812 Points
Let's break it down into steps:
int a = 3;
int b = 2;
double c = 3.5;
double y = a / b * c;
Since multiply and divide have equal precedence and left-to-right associativity, the first thing that will happen is:
a / b. These are both integers, and integer math produces integers, so:
3 / 2 = 1. Next, the
1 will be multiplied by
3.5, leaving it unchanged since it is a double and being assigned to a double. So the final result wil be:
Be aware that some quizzes scramble the question order each time they are used, so it's always best to cut and paste the actual question to identify the one you are working with.