C - 错误:预期标识符或'('返回0;

时间:2017-02-25 23:45:33

标签: c

一直想把它整理好几个小时。

我正在构建一个通用测试代码,尝试使用函数原型并使用它来找到一个简单的解决方案。

目标是让用户输入每两周工资的浮动值(I.E. 200.00等)并让程序获取函数并输出24个月*每两周一次的金额。

出于某种原因,我收到了错误,无法弄明白......

错误是:

prog.c:32:1: error: expected identifier or '('
return 0;
^
1 error generated.

任何帮助都很棒:)

#include <stdio.h>

// Function prototype
float YearPay(float value);

int main()
{

/* variable definition: */
float biweekly, totalYear;
biweekly = 1.0;

/* Prompt user for biweekly salary */

while (biweekly > 0.0)
{
    printf("Enter your standard bi-weekly check value after tax:\n ");
    scanf("%f", &biweekly);

if (biweekly > 0.0)
{
    // Call the YearPay function
    totalYear = YearPay(biweekly);
    printf("The yearly total monetary value with bi-weekly paychecks in the\
    amount of %f is %f\n",biweekly,totalYear);
}
else
    printf("Bi-weekly salary must be greater than 0.0!\n");
    }
}

return 0;

/* Function returning the yearly total value of all paychecks */
float YearPay(float value)
{
    return (float)value*24;
}

1 个答案:

答案 0 :(得分:1)

更改

else
    printf("Bi-weekly salary must be greater than 0.0!\n");
    }
}

return 0;

else
    printf("Bi-weekly salary must be greater than 0.0!\n");
    }
return 0;
}

如果您要格式化代码(现在很难阅读),您会很容易看到这一点。