我写一个简单的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; }更多推荐
错误印刷价值屏幕。最高最低值
发布评论