Reputation: 37
I'm a week into an intro programming class, and I'm having trouble with fixing what's supposed to be a relatively simple code. I keep getting an invalid type argument of unary '*' error.
#include <stdio.h>
#define PI 3.14159;
int main()
{
float r;
float area;
scanf("%f", &r);
area = PI * r * r;
printf("Area is %f", area);
return 0;
}
Could someone explain this, and how to fix it?
Upvotes: 2
Views: 1911
Reputation: 3172
You have to remove the extra ;
in the definition of the macro PI
. It is unnecessary for macro, and in your case results in syntax error after expansion.
Upvotes: 2
Reputation: 182744
#define PI 3.14159;
^
Drop the semicolon. Leaving it in, the code will expand to:
area = 3.14159; * r * r;
Upvotes: 10