为什么函数类型及变量类型由float 变为double后,执行不正常?
程序代码:
# include<stdio.h> float min(float,float); int main(void) { float num1,num2; float MinNum; printf("please enter two numbles('q' to quit)\n"); while(scanf("%f%f",&num1,&num2)==2) { MinNum=min(num1,num2); printf("the num is :%.2f\n",MinNum); printf("Do you want continue?\n"); } return 0; } float min(float x,float y) { // float min; if(x<y) return x; else return y; }
程序是这样的,当函数类型及变量类型变为double后,执行不正常,执行结果如下:
the num is :-925596044...(即垃圾值)