第二章 C数据类型

2.2 下面程序为变量x,y,z赋初值2.5,然后在屏幕上打印这些变量的值,程序中存在错误,请改正错误并写出正确的运行结果。

#include<stdio.h>
main()
{
printf(“These values are :\n”);
int x=y=2.5;
printf(“x=%d\n”,x);
printf(“y=%d\n”,y);
printf(“z=%d\n”,z);
}

答案如下

// An highlighted block
#include<stdio.h>
int main()
{
float x=2.5,y=2.5,z=2.5;
printf("These values are :\n");
printf("x=%f\n",x);
printf("y=%f\n",y);
printf("z=%f\n",z);
return 0;
}

连接第二章 C数据类型