Question: Write the code in c , to create a type called Appliance. Appliance should be a structure consisting of a string of length 5 0

Write the code in c, to create a type called Appliance. Appliance should be a structure consisting of a string of length 50 called name, an int called power_rating, and a double called hours_per day.
For example, it should be possible to use your type as follows:
Appliance toaster ={"toaster",1800,0.25};
Then, under the type definition, write a function called calculate_cost() that takes an Appliance and a cost for the power in cents per kW/h. This function should calculate the daily cost using the formula
daily_cost=power_rating1000hours_per_daycost
With the toaster numbers above,
printf("%d", calculate_cost(toaster,0.40));
should display 0.18.
Please note: you should not write a main() function. Assume that all necessary #include statements, the main function, and the printf statements to display output have all been implemented - these will be added under the code that you write. You should write only the structure definition and the calculate_cost function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!