#include <stdio.h>
#include <math.h>
double computeTemp(double, double, double, double, double, double);
void main(void)
{
double rm,deg,h,w,l,t;
double final_temp;
printf("For all calculations assume that pressure is constant at 101.325kPa,and the heat capacity of air is also constant at 0.718kJ/kg*K\n");
printf("Please enter the number of students in the room:\n");
scanf("%lf",&rm);
printf("Please enter a temperature in degrees Celcius:\n");
scanf("%lf",°);
printf("Please enter the height of the room in metres (m):\n");
scanf("%lf",&h);
printf("Please enter the width of the room in metres (m):\n");
scanf("%lf",&w);
printf("Please enter the length of the room in metres (m):\n");
scanf("%lf",&l);
printf("Please enter a time in minutes (min.):\n");
scanf("%lf",&t);
final_temp = computeTemp(rm,deg,h,w,l,t,final_temp);
printf("Number of students: %f\n",rm);
printf("Initial temperature in degrees Celcius: %f\n",deg);
printf("Height of room (m): %f\n",h);
printf("Width of room (m): %f\n",w);
printf("Length of room (m): %f\n",l);
printf("Time elapsed (min.):%f\n",t);
printf("Final Temperature in degrees Celcius: %f\n",final_temp);
}
double computeTemp(double num1, double num2, double num3, double num4, double num5, double num6)
{
double temp;
temp = ((101.325*28.97)*(num3*num4*num5))/8.314*(num2+273.15);
temp = temp*0.718;
temp = (((4.8*num1*num6)*(num2+273.15))/(temp));
temp = temp+(num2+273.15);
temp = temp-273.15;
return(temp);
}
我從函數調用刪除了一個double,並且出現了computeTemp參數太少的錯誤。我是新來的C語言編程,並使用代碼塊,這樣可以幫助我解決這個問題的任何信息將是非常讚賞錯誤:「computeTemp」的衝突類型(C)
PLZ使用CTRL + K縮進你的代碼 –
你的'computeTemp'的參數命名方案並不好。如果您不確切知道該功能在做什麼,則無法理解它。請使用更多描述性名稱。另外,請儘量避免[幻數](https://en.wikipedia.org/wiki/Magic_number_(編程))。 –