错误预期';'之前' {'代币

时间:2015-09-07 18:40:13

标签: c compiler-errors

我无法找到编译器所要求的内容!我是否添加了额外的&#34 ;;"或者我错过了一个?

#include <stdio.h>

int main()
{

float menu;
float cm;
float in;
float indif = 0.39;
float cmdif = 2.54;
float result1 = cm * indif;
float result2 = in * cmdif; 

printf("Choose your convertion: \n\n");
printf("1. Centimeter - Inches\n");
printf("2. Inches - Centimeter\n"); 
printf("I want: ");
scanf("%f", &menu);

if ( menu < 2 ) 
{
    printf("\n\nWelcome to Centimeter > Inches converter!\n\n");
    printf("Enter your cenitmeters: ");
    scanf("%f", &cm); 
    printf("%f centimeters equals to %.2f inches!", cm, result1);
}

else ( menu > 1 )
{
    printf("\n\nWelcome to Inches > Centimeter converter!\n\n");
    printf("Enter your inches: ");
    scanf("%f", &in); 
    printf("%f inches equals to %.2f centimeters!", in, result2);
}

return 0;
}

1 个答案:

答案 0 :(得分:4)

else ( menu > 1 )

应该是

else if ( menu > 1 )

else子句不能有条件。