what is the type of int*float?

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

what is the type of int*float?

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

the answer will come out as a float even for like 4.5*2 the answer will come out 9.0 instead of just 9.
this is called the type conversion and the precedence of float is greater than int thus answer must be in float
ints generally become floats whenever it'd be obvious for them to do so, floats never become ints unless you explicitly tell them to do so.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

It is float because most of the compilers does automatic type conversion during the semantic analysis phase. So, in general all the types of the variable involved in an expression are converted into one single type (The highest type .. in your case, float) before the equation is evaluated...
@carlsmith Your not completely wrong but that wouldn't be the best explanation because look at lets say 10/4 you would expect it to return 2.5 but it returns 2 so therefore it doesn't become a float when it needs to only when given a float. (kenators explanation is correct)
@Onyx - If you write the expression 10 / 4, you get 2 because this, at least in Python2, does floor division. It has nothing to do with intuitive type conversion. If you take the two ints, 10 and 4, and do sane division 10 // 4, you get 2.5, a float, as expected. In Python3, 10 / 4 returns a float and 10 // 4 returns an int. This is an issue with the counter-intuitive syntax of division operators before Python3, it's nothing to do with ints and floats.
Most people that take this course use 2.x because thats what the teacher uses. And I said you weren't completely wrong that just wasn't the best way to explain for someone that doesn't understand type conversion unless you already knew he was using 3.xsyntax.

Not the answer you are looking for?

Search for more explanations.

Ask your own question