Ask Question
20 September, 05:08

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.

+4
Answers (1)
  1. 20 September, 08:49
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers