c/c++语言开发共享编译器错误,我无法找到

我收到一个我无法解决的错误。 我彻底完成了我的代码但没有成功。 我究竟做错了什么? 见下面的代码。

编译错误:

In function 'main': ou1.c:49:1: error: expected 'while' before 'printf' printf("End of program!n"); ^ 

我的代码:

 #include  int main(void){ int choice; float price, sum, SUMusd; float rate =1; printf("Your shopping assistant"); do{ printf("1. Set exchange rate in usd (currency rate:%f)n", rate); printf("2. Read prices in the foreign currencyn"); printf("3. Endn"); printf("n"); scanf("%d", &choice); switch(choice){ case 1: printf("Give exchange rate: n"); scanf("%f", &rate); break; case 2: do{ printf("Give price(finsh with < 0)n"); scanf("%f", &price); sum =+ price; }while(price <= 0); SUMusd = sum*rate; printf("Sum in foreign currency: %f", sum); printf("Sum in USD:%f", SUMusd); break; default: printf("Invalid choicen"); break; }while(choice != 3); } printf("End of program!n"); return 0; } 

    在while循环终止之前,需要关闭switch语句的花括号。

    printf("Invalid choicen"); break; } }while(choice != 3); printf("End of program!n");

    更正了完整的代码示例

     #include  int main(void){ int choice; float price, sum, SUMusd; float rate =1; printf("Your shopping assistant"); do{ printf("1. Set exchange rate in usd (currency rate:%f)n", rate); printf("2. Read prices in the foreign currencyn"); printf("3. Endn"); printf("n"); scanf("%d", &choice); switch(choice){ case 1: printf("Give exchange rate: n"); scanf("%f", &rate); break; case 2: do{ printf("Give price(finsh with < 0)n"); scanf("%f", &price); sum =+ price; }while(price <= 0); SUMusd = sum*rate; printf("Sum in foreign currency: %f", sum); printf("Sum in USD:%f", SUMusd); break; default: printf("Invalid choicen"); break; } }while(choice != 3); printf("End of program!n"); return 0; } 

      以上就是c/c++开发分享编译器错误,我无法找到相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/519055.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐