What is the output of the following function and function call?
void calculateCost(int count, float& subTotal, float taxCost);
float tax = 0.0,
subtotal = 0.0;
calculateCost(15, subtotal,tax);
cout << "The cost for 15 items is " << subtotal
<< ", and the tax for " << subtotal << " is " << tax << endl;
//end of fragment
void calculateCost(int count, float& subTotal, float taxCost)
{
if ( count < 10)
{
subTotal = count * 0.50;
}
else
{
subTotal = count * 0.20;
}
taxCost = 0.1 * subTotal;
}
#include <iostream> using namespace std; void calculateCost(int count, float& subTotal, float taxCost) { if ( count < 10) { subTotal = count * 0.50; } else { subTotal = count * 0.20; } taxCost = 0.1 * subTotal; } int main() { float tax = 0.0, subtotal = 0.0; calculateCost(15, subtotal,tax); cout << "The cost for 15 items is " << subtotal << ", and the tax for " << subtotal << " is " << tax << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.