【发布时间】:2014-01-09 21:48:19
【问题描述】:
这个程序给了我错误的答案,比如 -88567.0000000000000 我不知道怎么了
#include<stdio.h>
#include<math.h>
main()
{
float voltage,current,result;
puts("hello please enter the voltage ");
scanf("%f",&voltage);
puts("\nhello please enter the current ");
scanf("%f",¤t);
result=calling(voltage,current);
// result from function calling
printf("the answer is %f",result); // display the result
getch();
}
float calling (float y,float x)
{
float ans;
ans=y+x;
return(ans);
}
【问题讨论】:
-
我们应该怎么知道?您没有向我们展示您使用的输入。
-
如何编译?
-
任何输入都会产生相同的数字,例如 -8633424.00000000
-
欢迎来到 SO。你的程序不应该编译和/或你的编译器应该用这样的代码给你很多诊断。在打扰其他人提问之前,请先考虑查看一些书籍或在线资源。