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 37
|
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int i;
double calcVolts(const double *current, const 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++)
{
voltage[i]= calcVolts(current, resistance, voltage);
cout<<"Voltage number "<< i+1 << " is: "<< voltage[i]<< endl;
}
return 0;
}
|