Question: Write a complete C program to calculate the power consumed voltage, and resistance for a set of electric devices with help of using the following

Write a complete C program to calculate the power consumed voltage, and resistance for a set of electric devices with help of using the following equations:

P = V * I R= V/ I V=R*I

Where P: power, R: resistance, I: current, V: voltage.

Note that your program should be able to read a set of pair-values voltage and current, or resistance and current from a text file named Electric.txt. The file can contain values for up to 100 device.

Hint: The second value is always the current. So, if the character is V thats mean the values are for voltage and current, but if the character is R thats mean the values are for resistant and current. See the sample input file below.

What to do?

Read the values from a file named Electric.txt.

For each device, compute the power voltage or resistance).

Use a two dimensional array to store the measurements of the devices in an array.

Find and print the average consumed power.

Sort the devices in ascending order based on the consumed power.

Print out the devices information on screen after sorting.

Your program should contain at least three functions, one of them using the concept of pointers.

Sample input file:

V

120

0.02

R

2000

0.05

R

320

0.002

V

100

0.02

V

20

0.025

V

80

0.1

R

920

0.08

Sample output screen:

Average power =3.3985

Device #1

Power= 0.0013

current= 0.0020

Volt= 0.6400

Resistance= 320.0000

Device #2

Power= 0.5000

current= 0.0250

Volt= 20.0000

Resistance= 800.0000

Device #3

Power= 2.0000

current= 0.0200

Volt= 100.0000

Resistance= 5000.0000

Device #4

Power= 2.4000

current= 0.0200

Volt= 120.0000

Resistance= 6000.0000

Device #5

Power= 5.0000

current= 0.0500

Volt= 100.0000

Resistance= 2000.0000

Device #6

Power= 5.8880

current= 0.0800

Volt= 73.6000

Resistance= 920.0000

Device #7

Power= 8.0000

current= 0.1000

Volt= 80.0000

Resistance= 800.0000

-------------------------------------------------------------------------------------------------------------------------------

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!