Hello everyone.

I've just started University and had a c++ Assignment due 2 days ago so I've already lost 20% of my marks.

Basically I've hit a roadblock and can't figure out how to use array values in an equation.


The program needs to calculate the Resistance total (r) values of a parallel circuit.
It needs to prompt the user for the value of resistor 1, then resistor 2 then resistor 3 and store those values in an array of size 3 (assignment criteria).

I've got the array working however I need to use the array values in an equation and no matter what I try it won't work.

So the program needs to do this.:

Enter R1:
Enter R2:
Enter R3:

Total resistance = 1/R1+1/R2+1/R3.

Answer = total resistance.

Here's the coding as you see I haven't done much so far. I've tried many different things even using r = 1/[0]+1/[1]+1/[2]. I have no idea why that doesn't work.

Code:
#include <iostream>
using namespace std;
 int main()
 {
    int myArray[3]; //Array of 3 integars
    int i;
    for (i=0;i<3;i++) //0-3
        {
        cout << "Enter the value of R" << i+1 << ": ";
        cin >> myArray[i];
        }
 
    int r, r1, r2, r3;
        myArray[0] = r1;
        myArray[1] = r2;
        myArray[2] = r3;
    
        cout <<r1<<"";
   
        /*r = 1/r1+1/r2+1/r3;
        cout << r;*/
        
        system("pause");
        return 0;
 }
That's my coding so far and it doesn't work properly, it prompts for the resistor values correctly then displays the answer however the answer is not evne close to been correct.

Can anyone please tell me what I'm doing wrong?