If we multiply an integer with float, data type of the result will be
please answer fast
Answers
Answered by
5
Answer:
When multiplying two integer values, the compiler will never by itself convert the result to a floating point type. That is, if you multiply two int values, the result too will be an int value.
So, what you're code is effectively doing is:
int a = 10;
int b = 20;
int tmp = a * b; // Result is actually an int
double c = (double)tmp; // Convert to a double.
Thus, the result would only overflow if it cannot be stored within an int. The conversion and assignment to a double is done only after the result is calculated.
hope it helps you!
Similar questions