error: expected ',' or ';' before numeric constant
I'm new to C programming and I keep getting the error message in the title. I'm following along with the Floating Point Math tutorial and I have compared my statements to the picture but I can't seem to find the problem. It wants me to Expand More Floating Point.c to calculate the volume of a sphere using v = 4/3 × π × r3.
Pre-written Loop:
include "simpletools.h" // Include simpletools
int main()
{
float r = 1.0;
float c = 2.0 * PI * r;
print (“circumference = %f \n”, c);
float a = PI * r * r; // <- add
print(“area =%f \n” , a); // <- add
}
My Loop:
include "simpletools.h" // Include simpletools
int main() // main function
{
float r = 1.0; // Set radius to 1.0
float v = 4.0\3.0 × PI × r^3.0; // Calculate volume
print("volume = %f \n", v); // Display volume
float v = 4.0\3.0 * PI * r * r * r; // <- add
print("volume = %f \n", v); // <- add
}
I'm getting the error for the calculate volume statement.
Comments
Is the divide operator slanted the correct way? Should it be \ or / ? The compiler may not recognize the \ and thinks you're trying to define a constant like the previous line. Just guessing.
Here are the corrections.
The backslash is not divide.
The two stars were not stars??? for multiple
r^3 is not supported.
once a variable is defined it doesn't need to be defined again.
Mike