错误印刷价值屏幕。最高最低值 [英] error printing value to screen. Max Min values

查看:78
本文介绍了错误印刷价值屏幕。最高最低值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个简单的code,它有两个数字输入并告诉我这是最高值,这是使用2个单独的文件功能最小值。这里是我的code为止。它扫描的数量和具有正确的最大最小,但是当我去打印值一个疯狂的打印数量。

I am writing an easy code that takes two numbers I enter and tells me which is the Max value and which is the Min value using 2 separate files for functions. here is my code so far. It scans the number and has the correct Max Min but when I go to print the values a crazy number prints.

#include<stdio.h>

 int main(void)
 {
     double num2, max, min, num1;

 printf("enter any space-separated pair of decimal numeric values on the same line: ");
 scanf("%le%le", &num1, &num2);


 max = ComputeMaximum(num1, num2);
 min = ComputeMinimum(num1, num2);


 printf("%le", max); 
 printf("%le", min);

return 0;
}

这是我的主要项目,在同一个项目中,我有单独的文件:

this is my main program, on seperate files in the same project I have:

double ComputeMinimum(double num1, double num2) {

    double result;

    result = (num1 < num2) ? num1 : num2;

    return result;
}

double ComputeMaximum(double num1, double num2) {

    double result;

    result = (num1 > num2) ? num1 : num2;

    return result;
}

我想有它打印到屏幕:
ComputeMinimum(?,?)回来?结果
ComputeMaximum(?,?)返回? (问号是值。)

I would like to have it print to screen: ComputeMinimum(?, ?) returned ?
ComputeMaximum(?, ?) returned ? (question marks are the values.)

推荐答案

code丢失的原型。

Code is missing prototypes.

这就是全部,格式是确定的,功能正常。

That is all, format is OK, functions are OK.

#include<stdio.h>

// Add these to the same file as main() 
// Or better yet, add to another file Compute.h and #include "Compute.h" 
// here and in the the separate C file
double ComputeMinimum(double num1, double num2);
double ComputeMaximum(double num1, double num2);

int main(void)
  ...

  // suggest adding check
  if (2 != scanf("%le%le", &num1, &num2)) {
    puts("Input error");
    return -1;
  } 

这篇关于错误印刷价值屏幕。最高最低值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆