HW

Can someone explain what Part C wants me to do?Homework 10
The present homework is concerned with the use of pointers in computing the equivalent resistance to resistors connected in series. You are to design six programs, and, in each of these programs, you are to use the following one-dimensional array
R[5]={10.00,20.00,30.00,40.00,50.00}
representing the values of the resistances in ohms of five resistors:

PROGRAM A:
Design a program using pointers but no prototype function which will compute the equivalent resistance to the given five resistors connected in series. Your program is to output the elements of the resistance array as well as the computed value of the equivalent resistance req.

PROGRAM B:
Modify the design in Program A so that now you are using a prototype function called SERIES placed after the main function. Your program is to output the elements of the resistance array as well as the computed value of the equivalent resistance req from within the main function.

PROGRAM C:
Modify the design in Program B so that now you are using two prototype functions which are both placed after the main function, one called PASSING and the other called SERIES. The prototype function SERIES is to be placed after the prototype function PASSING. In this program, the resistance array is passed to the prototype function PASSING where the prototype function SERIES, which is to do the actual calculation of the equivalent resistance req, is to be invoked. The value of req is to be returned to the prototype function PASSING which does the job of outputting of the elements of the resistance array as well as the computed value of the equivalent resistance req.

PROGRAM D:
Repeat Program C but this time place the prototype function SERIES immediately after the main function and the prototype function PASSING is placed after the prototype function SERIES.
iirc
1
2
3
4
5
void passing(double *resistors, int size){
   //TODO: output the value of the resistors

   std::cout << series(resistors, size); //output the total value
}
Last edited on
Topic archived. No new replies allowed.