# C++ program calculating current through a set of resistors

Writing a Program using Input and Output Arrays

Procedure:

1. You will write one C program. Name it as YOUR LAST NAME_Lab07.cpp

2. Lab07 will be used to calculate the current that flow through five separate resistors based on a user's input of voltage (using Ohm's Law). It will use two "input arrays" and produce one "output array".

3. One input array will identify each resistor by the following characters: R1, R2, R3, R4, and R5.

? {R1, R2, R3, R4, R5}

4. The other input array will contain the resistive value (in ohms) of each of the six resistors as: 1, 10, 100, 1000, 10,000.

? {1, 10, 100, 1000, 10000}

5. Your program will prompt the user to enter a floating-point value for the voltage.

6. Your program will then calculate the current flowing through each of the five resistors, element-by-element (hint: use a "pointer"), using Ohm's Law:

? Current (in amperes) = Electromotive Force (in volts) divided by Resistance (in ohms), or I = E / R

7. The computed current for each resistor is then stored into an output array, element-by-element (hint: use a "pointer").

? { , , , , } note that the 1st value (shown as empty space) will be the result of dividing voltage by R1, the 2nd value will be the result of dividing voltage by R2, etc.

8. Your program will then print out the results (with data from your output array) in the following format (note that both the user input voltage and resultant currents are just for this example output):

For your input of 10 volts,

The current through R1 is 10 amps
The current through R2 is 1 amps
The current through R3 is 0.1 amps
The current through R4 is 0.01amps
The current through R5 is 0.001 amps

© SolutionLibrary Inc. solutionlibary.com 9836dcf9d7 https://solutionlibrary.com/physics/electricity-magnetism/c-program-calculating-current-through-a-set-of-resistors-7dl1