【发布时间】:2015-06-29 11:22:15
【问题描述】:
请帮忙。我是编程新手。我现在专注于功能。基本上功能'排序'的作品。然而,从摄氏度转换为华氏温度的温度并不准确。任何关于为什么答案开始正常并且越来越错误的解释都会非常有帮助。谢谢。下面是代码:
#include <stdio.h>
#include <conio.h>
//function prototypes
float convertTofahrenheit(float z);
int main (void){
float x,y;
int count_c;
x=convertTofahrenheit(y);
printf ("%s\t%s","Celcius","Fahrenheit\n");
for (count_c=0;count_c<=30;count_c++){
x++;
printf ("%d\t%f\n", count_c, x);
}
getch();
return 0;
}
//function for conversion from Celcius to Fahrenheit
float convertTofahrenheit(float z){
float fahrenheit;
fahrenheit= ((z*1.8)+32);
return fahrenheit;
}
【问题讨论】:
-
您希望在
for循环中发生什么? -
这肯定不是您的实际代码。
y在对convertTofahrenheit的调用中未初始化。
标签: c floating-point integer double