error: expected identifier while compiling

error: expected identifier while compiling

这是我为了学习新功能而写的代码"round"。

 #include <stdio.h>
 #include <cs50.h>

 int main(void);
 float a = 0;
 float b = 0;
{

    do 
     {
         // Here we will ask fo the change.
         printf("How much change do I owe?\n");
         float a = GetFloat();
     }
     while (a <= 0);
    {
        // Use of new function round which will round off the float and conver it to int or any specified number format.
        float b = (int)round( a * 100);
        printf("%f\n", b);
    }
    return 0;
}

但是报错如下

greedy.c:6:1: 错误:预期标识符或“(” { ^ 产生 1 个错误。 make: *** [greedy] 错误 1

看起来你有一些语法和逻辑问题:

#include <stdio.h>
int main()
{
    float a = 0;
    do 
     {
         // Here we will ask fo the change.
         printf("How much change do I owe?\n");
         scanf("%f",&a);
         // Use of new function round which will round off the float and conver it to int or any specified number format.
         a = (int)(a * 100);
         printf("%f", a);
     }
     while (a <= 0);
    return 0;
}