196k views
4 votes
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);
printf( ""The cost for 15 items is %.2f, and tax for %.2f is %.2f"", subtotal, subtotal, tax);

//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;
}


A) The cost for 15 items is 3.00, and the tax for 3.00 is 0.00
B) The cost for 15 items is 3.00, and the tax for 3.00 is 0.30
C) The cost for 15 items is o.00, and the tax for 3.00 is 0.00
D) The cost for 15 items is 0.00, and the tax for 0.00 is 0.00

1 Answer

5 votes

Final answer:

The cost for 15 items is 0.00, and the tax for 3.00 is 0.30

Step-by-step explanation:

The output of the function and function call mentioned in the question is:

The cost for 15 items is 0.00, and the tax for 3.00 is 0.30

In the given function, if the count variable is less than 10, the subtotal is calculated by multiplying the count by 0.50. Otherwise, the subtotal is calculated by multiplying the count by 0.20. The tax cost is then calculated by multiplying 0.1 with the subtotal.

Since the count in the function call is 15, which is greater than 10, the subtotal is calculated using 15 * 0.20, resulting in a value of 3.00. The tax cost is calculated using 0.1 * 3.00, resulting in a value of 0.30. Therefore, the output is as mentioned above.

User Sdcvvc
by
8.8k points