190k views
4 votes
Write a C function (NOT A COMPLETE PROGRAM)which takes three parameters which are the cost for an item in a grocery store, the quantity to buy, and the tax percentage. The function should calculate and returnthe following values:i. The cost before the tax amount(cost* quantity)ii. The taxamount (the cost before the tax amount* tax% / 100)iii. The cost with the tax amount(the cost before the tax amount the tax amount) for the item.

1 Answer

6 votes

Answer:

Check the explanation

Step-by-step explanation:

#include <stdio.h>

void CalculateTotal(float cost,int quantity,int tax){

float costbeforetax=cost*quantity;

printf("\\Total Cost Before Tax %f is ",costbeforetax);

float taxamount=(costbeforetax*tax)/100;

printf("\\ Tax amount %f is ",taxamount);

float total=costbeforetax+taxamount;

printf("\\ Total amount after Adding Tax %f is ",total);

}

int main()

{

float cost;

int quantity,tax;

printf("Enter Cost of Item ::");

scanf("%f",&cost);

printf("Enter Quantity of Item ::");

scanf("%d",&quantity);

printf("Enter Tax in % ::");

scanf("%d",&tax);

CalculateTotal(cost,quantity,tax);

return 0;

}

/*

The Output will look like this:

Enter Cost of Item ::10

Enter Quantity of Item ::5

Enter Tax in % ::23

Total Cost Before Tax 50.000000 is

Tax amount 11.500000 is

Total amount after Adding Tax 61.500000 is

*/

User Shubham Sahu
by
7.3k points

No related questions found