cheers this worked however I'm now having the same problem with another code and i cannot see why. see below
Code:
int main()
{
printf("-- Wind turbine power calculator -- \n");
double A, V, Cp, Ng, Nb, p, Pwr, d, a, h;
A = getType();
d = getDiameter();
a = getAltitude();
V = getVelocity();
Cp = getPerformance();
Ng = getGenerator();
Nb = getGearbox();
p = density(a);
printf("density =%lf \n", p);
Pwr = p*Cp*0.5*Ng*Nb*pow(V,3);
printf("Power =%0.3lf \n", Pwr);
return 0;
}
this is my main code i now have the correct density however same as before the power is outputting wrong values. the functions for the variables in the Pwr equation all look like this:
Code:
double getPerformance()
{
double Cp;
printf("\nEnter performance coefficient:");
scanf("%lf", &Cp);
if ( Cp > 0.56)
{
printf("Invalid input! performance coefficient must be between 0.35 and 0.56");
return getPerformance();
}
else if (Cp < 0.35)
{
printf("Invalid input! performance coefficient must be between 0.35 and 0.56");
return getPerformance();
}
return Cp;
}
the equation for power is P = (0.5 x Ng x Nb x Cp x p x V^3)
do you see anything wrong with these codes also? your help is greatly appreciated.
cheers