Writing a program using input and output arrays


Writing a Program using Input and Output Arrays

Procedure:

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

Question 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”.

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

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

Question 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}

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

Question 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

Question 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.

Question 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

Solution Preview :

Prepared by a verified Expert
Physics: Writing a program using input and output arrays
Reference No:- TGS01892395

Now Priced at $30 (50% Discount)

Recommended (93%)

Rated (4.5/5)