modifying an array in main using another function

I need to pass 3 arrays to a function, set the 3rd equal to the 1st multiplied by the 2nd, and have the main function give the values of the 3rd array. I've been working on this for hours and have no idea what I'm doing wrong
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  #include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int i;

double calcVolts(double *current, double *resistance, double *voltage)
{
    
    for(i=0; i<10; i++)
   { 
      voltage[i] = current[i] * resistance[i];
   }

return voltage[i];
}

int main()
{
 const int num=10;  
   double current[num] = {10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98};
   double resistance[num] = {4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, 4.8}; 
   double voltage[num];
   for (int i=0; i<num; i++)
   {
   cout<<"Voltage number "<< i+1 << " is: "<< voltage[i]<< endl;
   }
   return 0;
}




Last edited on
You never call your calcVolts function.

By the way, that function also returns an out-of-bounds array element.
How would I go about calling calcVolts? And what should I have it return then?
Topic archived. No new replies allowed.