2.12 Type conversions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Type the value of the expression given int numItems = 5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. 3.0 / 2

1.5

Type the value held in the variable after the assignment statement, given int numItems = 5, and double itemWeight = 0.5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. someIntVar = itemWeight * numItems; (someIntVar is type int).

2

Type the value of the expression given int numItems = 5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. 3.0 / 1.5

2.0

Type the value held in the variable after the assignment statement, given int numItems = 5, and double itemWeight = 0.5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. someDoubleVar = itemWeight * numItems; (someDoubleVar is type double).

2.5

Type the value of the expression given int numItems = 5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. (numItems + 10) / 2

7

Type the value of the expression given int numItems = 5. For any floating-point answer, type answer to tenths. Ex: 8.0, 6.5, or 0.1. (numItems + 10) / 2.0

7.5

Compute the average kids per family. Note that the integers should be type cast to doubles. #include <iostream> using namespace std; int main() { int numKidsA; int numKidsB; int numKidsC; int numFamilies; double avgKids; numKidsA = 1; numKidsB = 4; numKidsC = 5; numFamilies = 3; Write it in here cout << "Average kids per family: " << avgKids << endl; return 0; }

avgKids = (double) (numKidsA + numKidsB + numKidsC) / numFamilies;

Which yields 2.5? a. static_cast<int>(10) / static_cast<int>(4) b. static_cast<double>(10) / static_cast<double>(4) c. static_cast<double>(10 / 4)

b

Given aCnt, bCnt, and cCnt are integer variables, which variable must be cast to a double for the expression (aCnt * bCnt) / cCnt to evaluate to a double value? a. None b. All variables c. Only one variable

c

Which does NOT yield 3.75? a. static_cast<double>(15) / static_cast<double>(4) b. static_cast<double>(15) / 4 c. 15 / static_cast<double>(4) d. static_cast<double>(15 / 4)

d

Determine the resulting type for each expression. Assume numSales1, numSales2, and totalSales are int variables. Int or double. (numSales1 + numSales2) / static_cast<double>(totalSales)

double

Determine the resulting type for each expression. Assume numSales1, numSales2, and totalSales are int variables. Int or double. static_cast<double>(numSales1 + numSales2) / 2

double

Determine the resulting type for each expression. Assume numSales1, numSales2, and totalSales are int variables. Int or double. (numSales1 + numSales2) / 2

int

Determine the resulting type for each expression. Assume numSales1, numSales2, and totalSales are int variables. Int or double. (numSales1 + numSales2) / totalSales

int


संबंधित स्टडी सेट्स

Capitalization 2-Which word is incorrectly capitalized?

View Set

chapter 35 assessment of musculoskeletal function

View Set

La democrazia del talk show. Storia di un genere che ha cambiato la televisione, la politica, l'italia

View Set