Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Why does transfer matter?

Answered: 1 week ago

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago