gpt4 book ai didi

c - ';' token 之前应出现错误 '{'

转载 作者:行者123 更新时间:2023-11-30 21:16:18 25 4
gpt4 key购买 nike

我找不到编译器要求的内容!我是否添加了额外的“;”还是我少了一个?

#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;
}

最佳答案

else ( menu > 1 )

应该是

else if ( menu > 1 )

else 子句不能有条件。

关于c - ';' token 之前应出现错误 '{',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32444424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com