我不明白给定程序如何提供输出

时间:2011-06-22 03:16:00

标签: c++

我正在Turbo C ++ Version 4.5上编译这个程序

&安培;我输出为“C ++”..还告诉我“0.7f”在这里是什么意思?

#include<stdio.h>
int main()
{
float a=0.7;
if(a<0.7f)
printf("C\n");
else
printf("C++\n");
}

2 个答案:

答案 0 :(得分:1)

这是非常基本的,您应该阅读constants

数字后,

f将其声明为单精度浮点数。在您的代码中,它打印C ++,因为变量a确实不小于0.7f

答案 1 :(得分:1)

"Floating point: Accuracy problems"

f后缀意味着它是一个32位单精度浮点数,而不是文字本来可能的普通64位双精度浮点数。