Ask Question
10 January, 18:50

Assume a program has the following variable definitions:

int units;

float mass;

double weight;

and the following statement

weight = mass * units;

Which automatic data type conversion will take place?

a) mass is demoted to an int, units remains an int, and the result of mass * units is an int.

b) units is promoted to a float, mass remains a float and the result of mass * units is a float.

c) units is promoted to a float, mass remains a float and the result of mass * units is a double.

+2
Answers (1)
  1. 10 January, 19:02
    0
    C

    Explanation:

    As the unit is defined as integer type i. e. unit will have whole number, mass is defined as float data type which will have fractional values, and weight is defined as double data type which can have both values i. e. fractional value or integer value.

    If you multiply an integer value by a fractional/decimal value it will give fractional value (unit value will promote to fractions).

    Thus, result will be fractional value so result of unit*mass will be double.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume a program has the following variable definitions: int units; float mass; double weight; and the following statement weight = mass * ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers