Simple Circuit Power Calculation 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.

Inputs

Input will consist of the voltage of the power source and the value of the resistance.

Outputs

Print the power used and 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. Here are some notes on creating and compiling this solution. The output from this is
--> g++ -o circuit1 circuit1.c
--> ./circuit1
Enter the voltage in volts 10
Enter the resistance in ohms 10
The power value is 10 watts
The current value is 1 amperes