Simple Circuit Power Calculation Table Problem

Circuit picture from ohmslaw.com

I want you to do some simple calculations on a very simple circuit. The circuit consists of a power source, a resistance load and a couple of wires. You are going to calculate the power used by the circuit and the current flowing through it. The equation for power is:

	power = volts2 / resistance

And current is determined by

	current = volts/resistance

Voltage is measured in, well, volts, resistance in ohms, power in watts and current in amperes.

In this problem, the resistance is a fixed value, say 10 ohms. You are given a range of voltage values, expressed as the low and high values for the range. You will then calculate the power and current for each voltage value in the range in steps of 1 volt.

Inputs

Input will consist of the lower and upper values for a range of voltages of the power source.

Outputs

Print the table showing three columns, one for the voltage, one for the power used and one for the current produced.

Notes

Watch out for arithmetic errors and think about the range and domain of the equations.

Answer

Here is one solution to this problem. There are others. The output from this is
--> g++ -o circuit2 circuit2.c
--> ./circuit2
Enter the lower voltage value in volts 10
Enter the higher voltage value in volts 20
Voltage (volts) Power (watts)   Current (ohms)
10      10      1
11      12.1    1.1
12      14.4    1.2
13      16.9    1.3
14      19.6    1.4
15      22.5    1.5
16      25.6    1.6
17      28.9    1.7
18      32.4    1.8
19      36.1    1.9
20      40      2