Purchase Solution

C++ program with arrays calculating current in resistors

Not what you're looking for?

Ask Custom Question

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

Attachments
Purchase this Solution

Solution Summary

A simple C++ console program that will calculate output current through each resistor given an input Voltage. Makes use of Ohm's law. Uses arrays to store resistors and outputs the results on the screen.

Purchase this Solution


Free BrainMass Quizzes
Variables in Science Experiments

How well do you understand variables? Test your knowledge of independent (manipulated), dependent (responding), and controlled variables with this 10 question quiz.

Introduction to Nanotechnology/Nanomaterials

This quiz is for any area of science. Test yourself to see what knowledge of nanotechnology you have. This content will also make you familiar with basic concepts of nanotechnology.

Intro to the Physics Waves

Some short-answer questions involving the basic vocabulary of string, sound, and water waves.

Classical Mechanics

This quiz is designed to test and improve your knowledge on Classical Mechanics.

The Moon

Test your knowledge of moon phases and movement.