>>I need some help writing this program
Which part are you confused about? We are not going to write the program for you. So you might as well do what you can, post your program, and ask specific questions. The instructions seem to be pretty clear to me.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
you are attempting to duplicate the symbol name of the array and a variable. Variable names can not be duplicated.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
volts[MAXNUMS] is the name of an array
volts = 0 is the name of a simple integer
They must have different names
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
for (k = 0; k < MAXNUMS; k++) // Display and calculate the voltage
{
cout << "The voltage is " << volts[k] << endl;
volts[k] = current[i] * resistance[j];
}
not 'Display and calculate the voltage'
but 'calculate first and then display the voltage'
swap the two lines in the for loop.
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
for (k = 0; k < MAXNUMS; k++) // calculate and display the voltage
{
volts[k] = current[<strong>k</strong>] * resistance[<strong>k</strong>];
cout << "The voltage is " << volts[k] << endl;
}
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287
See index values shown in RED. You should have used k instead of i and j.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Use cout to put the column lables you want between the second and third loop. Then format the output statement in the third loop so the output lines up under the appropriate label.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
Are you dumber than a box of rocks?
Do none of these comments mean anything to you?
Last edited by Ancient Dragon : 1 Day Ago at 03:19. Reason: add code tags
Last edited by Ancient Dragon : 1 Day Ago at 04:53. Reason: add code tags
Last edited by Ancient Dragon : 1 Day Ago at 04:55. Reason: This is the third time I've had to add code tags
Last edited by Ancient Dragon : 8 Hours Ago at 23:36. Reason: add code tags -- 4th attempt
Are you not even the tiniest bit curious as to why your posts change to be nicely formatted?
Did you even bother to read this thread?
http://www.daniweb.com/forums/announcement8-3.html
Do you even notice the water mark at the back of the edit window telling you about code tags?
Have you ever considered using the "preview post" feature to make sure you're presenting your question in the best possible light?
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953