【问题标题】:EASY C++ (function call) [closed]EASY C++(函数调用)[关闭]
【发布时间】: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",&current);

    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。你的程序不应该编译和/或你的编译器应该用这样的代码给你很多诊断。在打扰其他人提问之前,请先考虑查看一些书籍或在线资源。

标签: c function call


【解决方案1】:

放置原型

float  calling (float y,float x);

在主之前

【讨论】:

    猜你喜欢
    • 2017-02-19
    • 2012-11-26
    • 2015-02-10
    • 1970-01-01
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多