高手帮我看看,为什么输出的结果不对!!!!!谢谢了。。。
只是一个简单的米和英尺转化的程序,我设置的精度为double,结果显示错误,请帮我查找下错误:double\float到底有什么区别呢???
#include <stdio.h>
double Transform1();
double Transform2();
void main() //meter and feet bilateral transform
{
printf("please choose the mode you want to transform:\n");
printf("a. from meter to feet\n");
printf("b. from feet to meter\n");
char s;
s = getchar();
switch(s)
{
case 'a': Transform1();break;
case 'b': Transform2();break;
}
}
double Transform1()
{
printf("you have selected the mode (from meter to feet), please input the number:\n");
double temp, res;
scanf("%f",&temp);
res=temp*3.28;
printf("the result is :%f\n",res);
return res;
}
double Transform2()
{
printf("you have selected the mode (from feet to meter), please input the number:\n");
double temp, res;
scanf("%f",&temp);
res=temp*0.3;
printf("the result is :%f\n",res);
return res;
}