Section 2.13 Check Point Questions6 questions
2.13.1
Can different types of numeric values be used together in a computation?
2.13.2
What does an explicit casting from a double to an int do with the fractional part of the double value? Does casting change the variable being cast?
2.13.3
Show the output of the following code:
double f = 12.5; int i = f; cout << "f is " << f << endl; cout << "i is " << i << endl;
2.13.4
If you change static_cast<int>(tax * 100) / 100.0
to static_cast<int>(tax * 100) / 100 in line 12 in Listing 2.10,
what will be the output for the input purchase amount of 197.556?
2.13.5
Show the output of the following code:
double amount = 5; cout << amount / 2 << endl; cout << 5 / 2 << endl;
2.13.6
Write an expression that rounds down a double value in
variable d to an integer. Write an expression that rounds a double value in
variable d to an integer.