【发布时间】:2017-01-07 08:06:25
【问题描述】:
我是 C 编程的新手。老实说,这是我第一个使用 Function 的程序。但它不起作用。谁能告诉我应该是什么问题?
// Convert freezing and boiling point of water into Fahrenheit and Kelvin
#include<stdio.h>
void calculation(int);
void freezingCalculation(void);
void boilingCalculation(void);
int main (){
int temperature, fahrenheit, kelvin;
void freezingCalculation(void){
int temperature = 0;
calculation(temperature);
printf("Freezing point in Fahrenheit is %d. \n", fahrenheit);
printf("Freezing point in Kelvin is %d. \n", kelvin);
}
void boilingCalculation(void){
int temperature = 100;
calculation(temperature);
printf("Boiling point in Fahrenheit is %d. \n", fahrenheit);
printf("Boiling point in Kelvin is %d. \n", kelvin);
}
void calculation(int temperature){
//Temperature in fahrenheit
fahrenheit = ((temperature * 9) / 5) + 32;
//Temperature in Kelvin
kelvin = temperature + 273;
}
}
【问题讨论】:
-
你能用错误信息的实际细节、行号或未定义的函数来更新你的答案吗?
-
您可能希望在编写更多代码之前获得a good book on C - 研究它会为您节省大量时间和烦恼。
-
感谢您的建议。 @保罗R
-
代码中现在没有错误消息。它只是不打印报表。 @miltonb
标签: c nested-function