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>
using namespace std;
double calc_power(double,double, double, double&, double&, double&);
int main()
{
double volt,res,react,realpow,reactpow,appapower;
cout<<"Enter voltage = ";
cin>>volt;
cout<<"Enter resistance = ";
cin>>res;
cout<<"Enter reactamce = ";
cin>>react;
calc_power(volt,res,react,realpow,reactpow,appapower);
cout<<"The apparent power is " << appapower << endl;
cout<<"The real power is "<<realpow<<endl;
cout<<"The reactive power is " <<reactpow<<endl;
}
double calc_pow(double volt, double res, double react, double& realpow, double& reactpow, double& appapower)
{
double v = pow(volt,2);
double r = pow(res,2);
double x = pow(react,2);
double realp = pow(realpow,2);
double s = pow(appapower,2);
double c1 = - (res) / (r + x);
double c2 = res / ( r + x );
appapower = v * c1 ;
realpow = v * c2 ;
reactpow = sqrt( realp + s );
return realpow;
return reactpow;
return appapower;
}
|