The error I'm getting is "expected identifier or '(' before float." Any help would be appreciated. I've read it might have to do with the semi colon after fprod? I've tried adding parenthesis like (float) fsum and (float) fprod, as well as removing the semi colon both with and without parenthesis.
int main (void)
{
int x, y, z, fx, fy, fz, sum, prod, float fsum, float fprod;
//The error occurs on line 9. The above is line 9
printf("\n Enter the first integer number: ");
scanf("%d", &x);
if( x<=0){
printf("\n Invalid entry. Entry must be greater than 0.");
scanf("%d",&x);
}
printf("\n Enter the second integer number: ");
scanf("%d", &y);
if( y<=0){
printf("\n Invalid entry. Entry must be greater than 0.");
scanf("%d",&y);
}
You can't declare different types of variables in the same declaration. Change
to
As some comments have pointed out, it's bad practice to just group all the variables into a single declaration. It's better to split them up based on function or locality. This is really dependant on your program but you can do something like this:
Also, it's a good idea to initialize your variables to some sane values since they will contain random undefined values and if you try to use them without successfully setting them, you could end up with hard to find bugs. So: