Question

Write a program that calculates voltage from current and resistance values. Create three one-dimensional arrays named...

Write a program that calculates voltage from current and resistance values.

Create three one-dimensional arrays named current, resistance and voltage, each capable of holding 10 double-precision values. The values stored in current and resistance are as follows:
current = 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98
resistance = 4.0, 8.5, 6.0, 7.35, 9.0, 15.3, 3.0, 5.4, 2.9, 4.8

Have your program pass these three arrays to a function called calcVolts() which calculates the elements in the voltage array as the product of the equivalent elements in the current and resistance arrays, for example:
voltage[1] = current[1] * resistance[1]

Write the calcVolts() function (prototype, header, body) using pointers.

After calcVolts() has calculated and placed values in the voltage array, display the values in the arrays from within main() as follows:

voltage = current x resistance
42.48 10.63 4.00
126.56 14.89 8.50
79.26 13.21 6.00
...... ...... ......
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{

const int max_num = 10;
int k;

double current[max_num], resistance[max_num], calc_volts[max_num];

for (k = 0; k < max_num; k++ )
{

cout << "Please Enter the ten values given for resistance:";
cout << "10.62, 14.89, 13.21, 16.55,\n\n 18.62, 9.47, 6.58, 18.32,";
cout << " 12.15, 3.98 or any ten values of your choice\n :";
cin >> current[k];

cout << "Now enter ten values for the resistance:\n";
cout << "4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, 4.8.\n";
cout << " or any ten values of your choice.\n\n";
cin >> resistance[k];
}




for (k = 0; k < max_num; k++ )
{
calc_volts[k] = current[k] * resistance[k];
}


cout << "\nCurrent Resistance Volts" << endl;

for (k = 0; k< max_num; k++ )
{
cout << setw(7) << current[k] << setw(11) << resistance[k]
<< setw(11) << calc_volts[k] << endl;
}
}

]

Add a comment
Know the answer?
Add Answer to:
Write a program that calculates voltage from current and resistance values. Create three one-dimensional arrays named...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program that specifies three parallel one dimensional arrays name length, width, and area....

    Write a java program that specifies three parallel one dimensional arrays name length, width, and area. Each array should be capable of holding a number elements provided by user input. Using a for loop input values for length and width arrays. The entries in the area arrays should be the corresponding values in the length and width arrays (thus, area[i] =   length [i]* width [i]) after data has been entered display the following output: (in Java)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT