HELPPPPPP ......这是我的用户输入的温度读数代码,但我真的不确定我的代码有什么问题。当我编译时,它说“ else之前的预期表达”。我需要帮助,在此先感谢。

#include <stdio.h>

   main()
   {
   double lowest = 38;
   double temp;
   char bpower;

   printf("Enter temperature(C):");
   scanf("%lf", &temp);

   if(temp<lowest)
   {

     lowest = temp;

   }

     printf("Backup power on? (Y/N):");
     fflush(stdin);
     scanf("%c", &bpower);

    if(temp < 50);
    {

    printf("Normal mode of operation\n");
    printf("Continue to read the next temperature\n");

    }

    else

    {

       if(temp < 80)

       {
        printf("Turn on circulating fan\n");
        printf("Continue to read the next temperature\n");

       }


       else

       {
         if(bpower == 'N')



        {
        printf("Turn off equipment\n");
        printf("Lowest temperature is %.2f", lowest);

        }

        else

        {

         printf("Continue to read the next temperature\n");

         }

      }



 }
}

最佳答案

您的if语句之一中有一个分号。更改此:

if(temp < 50);
{

printf("Normal mode of operation\n");
printf("Continue to read the next temperature\n");

}


对此:

if(temp < 50)
{

printf("Normal mode of operation\n");
printf("Continue to read the next temperature\n");

}

07-26 01:37