Ask Question
1 December, 22:04

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. 1 December, 22:56
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers