Suppose the function from Display 3.7 has the return statement removed. Which of the statements below regarding this change are correct? Why?
```
void iceCream(int number, double totalWeight)
{
if(number == 0)
{
cout << “cannot divide among zero customers.\n”;
return;
}
portion = totalWeight/number;
cout << “Each one receives “
<< portion << “ ounces of ice cream.” <
```
a) The code will not compile.
b) The code will compile and run. The output will be unchanged.
c) The code will compile. For a zero number of customers the code would produce a divide by zero run-time error.
d) The program will compile and run correctly for 1 or more customers. The error for zero number of customers could be repaired by placing an else after the block belonging to the if.
c) The code will compile. For a zero number of customers the code would produce a divide by zero run-time error., and d) The program will compile and run correctly for 1 or more customers. The error for zero number of customers could be repaired by placing an else after the block belonging to the if.
a) and b) are foils for the unwary.
You might also like to view...
To what aspects of networking does data communications refer?
What will be an ideal response?
Which tool should you use if you are adding a native-boot VHD to an older computer, such as one running Windows XP?
a. Bcdboot b. Sysprep c. ImageX d. Fdisk
Alerts can run uploaded scripts.
a. true b. false
The ________ approach to systems implementation is considered the riskiest.
A. parallel B. pilot C. direct D. phased