I have read other questions like this but none seemed to work... My code is:
int flowRateFormula(int pipeDiameter,double velocity)
{
int integer3;
integer3=PI*(1/4)*(pow(pipeDiameter,2))*velocity;
return integer3;
}
And the error is:
flowRate.c: In function ‘flowRateFormula’:
flowRate.c:38:13: error: invalid type argument of unary ‘*’ (have ‘int’)
What to do? BTW PI IS DEFINED
Most likely you have the line
#define PI
somewhere, which causes your code to be equivalent to:
integer3=*(1/4)*....
and this fails to compile. Replace it with e.g.
#define PI 3.1416
Note also that (1/4)
will be evaluated to 0, because integer division returns an integer. you probably want to use 1.0/4.0
.