# Thread: expected ) before ; token

1. ## expected ) before ; token

i'm trying to get the program to run (M/m)^(1/5) and its telling me
% gcc lab4.c
lab4.c: In function âspeeds_ratioâ:
lab4.c:34:20: error: expected â)â before â;â token

where in my code did I make a wrong turn? help please!!!

Code:
```#include <stdio.h>
#include <math.h>

#define one 1.0;
#define five 5.0;

double speeds_ratio(double M,double m);

int main(void)
{

double Max;
double min;

printf("Input the max rpm.\n");
scanf("%lf",&Max);
printf("Input the min rpm.\n");
scanf("%lf",&min);

printf("The ratio between successive speeds of a six-speed gearbox with maximum speed %f rpm,and minimum speed %.1f rpm, is. %1f",Max,min,speeds_ratio(Max,min));

return(0);
}

double
speeds_ratio(double M, double m)
{

double (speed);

(speed) = pow(M/m,one/five);

return(speed);
}``` 2. #define statements in C are nothing more than fancy text substitution. If you have a ; in your #define, it gets put in the text. So when the preprocessor runs, and substitutes one and five, you get:
Code:
`(speed) = pow(M/m/1.0;/5.0;);`
See the extra semicolon? Drop the ; from the definition of one and five.

Also, you're a bit parentheses-happy. Using too many just makes your code difficult to read. Only use them when needed to force the order of operation, or when it clarifies your intention or improves readability. I would do the following:
Code:
```double
speeds_ratio(double M, double m)
{
double speed;  // not needed on declaration

speed = pow(M/m,one/five);  // not needed on left side of =.

return speed;  // not needed for return, it's a keyword, not a function
}``` 3. Oh, and since you're using GCC to compile your code, you can use the -E option to see the result of your preprocessed code. You may get a lot of "junk" at the beginning that doesn't interest you, but:
Code:
```\$ gcc -E foo.c
<snipped for brevity>
double speeds_ratio(double M,double m);

int main(void)
{

double Max;
double min;

printf("Input the max rpm.\n");
scanf("%lf",&Max);
printf("Input the min rpm.\n");
scanf("%lf",&min);

printf("The ratio between successive speeds of a six-speed gearbox with maximum speed %f rpm,and minimum speed %.1f rpm, is. %1f",Max,min,speeds_ratio(Max,min));

return(0);
}

double
speeds_ratio(double M, double m)
{

double (speed);

(speed) = pow(M/m,1.0;/5.0;);

return(speed);
}```
See, there are those unnecessary semicolons in red. Popular pages Recent additions 