c语言数据类型陈述,麻烦,如果C语言中的陈述与计算相结合
好吧,伙计们,我对此有一段时间。目前,我正在研究C语言中的if语句(很明显,编程介绍),我似乎无法得到if else语句正确的语法。我浏览过网页,但没有找到任何相关答案。我目前收到的错误是: | 47 | error:expected')'数字常量之前|麻烦,如果C语言中的陈述与计算相结合
#include
#include
#include
float p(float r, float v)
{
return (v*v)/(r);
}
int main()
{
float r, v, answer; //The user input and print for title of values
puts("Enter Voltage:");
scanf("%f", &r);
puts("Enter Resistance:");
scanf("%f", &v);
answer = p(v, r);
printf("Pd=%.9f\n", answer);
return 0;
scanf("%f", answer);
if (answer >= 0.25)
{
/* if condition is true then print the following */
printf("WARNING: Power Dissipation should not exceed 1/4 Watt\n");
}
else if ((answer) 0.25 < =<0.5 >)
{
printf("WARNING: Power Dissipation should not exceed 1/2 Watt\n");
}
scanf("%f", &answer);
if ((answer 0.5< & 1 >=< 1)
printf("WARNING: Power Dissipation should not exceed 1 Watt");
}
如果您有空余时间,请帮忙。
+0
这将有助于缩进代码。 –
2014-10-17 20:23:36
+4
你的第二个和第三个'if'语法错误。请查看您的课程笔记。 (关于重读:我甚至无法理解你想要测试的内容......) –
2014-10-17 20:23:52
+3
看起来你在你的主体中间有一个'return'。这可能是不对的。 –
2014-10-17 20:25:09