早教吧作业答案频道 -->其他-->
#includemain(){inta=0x7fffffff,b=025;floatf1=123.456,f2=2.0;charc1,c2;cl='a';c2='b';printf("a=%d,b=%d\n",a,b);printf("c1=%c,c2=%c\n",c1,c2);printf("fi=%e,f2=%f\n",f1,f2);a=f1;b=f2;printf("a=%d,b=%d\n",a,b);}D:\课件\VC6\MyProjects\d\d.c(5):warn
题目详情
#include
main()
{
int a=0x7fffffff,b=025;
float f1=123.456,f2=2.0;
char c1,c2;
cl='a';
c2='b';
printf("a=%d,b=%d\n",a,b);
printf("c1=%c,c2=%c\n",c1,c2);
printf("fi=%e,f2=%f\n",f1,f2);
a=f1;
b=f2;
printf("a=%d,b=%d\n",a,b);
}
D:\课件\VC6\MyProjects\d\d.c(5) :warning C4305:'initializing' :truncation from 'const double ' to 'float '
D:\课件\VC6\MyProjects\d\d.c(7) :error C2065:'cl' :undeclared identifier
D:\课件\VC6\MyProjects\d\d.c(12) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
D:\课件\VC6\MyProjects\d\d.c(13) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
执行 cl.exe 时出错.
哪里错了请大神指教呀
main()
{
int a=0x7fffffff,b=025;
float f1=123.456,f2=2.0;
char c1,c2;
cl='a';
c2='b';
printf("a=%d,b=%d\n",a,b);
printf("c1=%c,c2=%c\n",c1,c2);
printf("fi=%e,f2=%f\n",f1,f2);
a=f1;
b=f2;
printf("a=%d,b=%d\n",a,b);
}
D:\课件\VC6\MyProjects\d\d.c(5) :warning C4305:'initializing' :truncation from 'const double ' to 'float '
D:\课件\VC6\MyProjects\d\d.c(7) :error C2065:'cl' :undeclared identifier
D:\课件\VC6\MyProjects\d\d.c(12) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
D:\课件\VC6\MyProjects\d\d.c(13) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
执行 cl.exe 时出错.
哪里错了请大神指教呀
▼优质解答
答案和解析
错误是因为,你定义的char c1,你在下面赋值写的cl,所以error错误是 没有定义cl.至于你发的warning是警告,意思是float转int可能会损失精度.
看了 #includemain()...的网友还看了以下:
下列四个单位中,是电场强度E的单位的是()A.N/CB.C/kgC.V•mD.N•m2/C2 2020-05-13 …
#includemain(){inta=0x7fffffff,b=025;floatf1=123. 2020-05-19 …
三个电容器,电容分别为C1,C2,C3,C2与C3并联,(C2与C3并联)与C1串连,加载电路两端 2020-07-09 …
化学~~~~高学历的来~[编辑本段]理想气体状态方程式的推导过程首先对于同样摩尔质量n=1的气体有 2020-07-09 …
请帮忙把指标公式编个选股公式N:=5;J:=4;A1:=REF(H,N)=HHV(H,2*N+1) 2020-07-09 …
为什么printf("a%cb%c\bc%c\tabc\n",c1,c2,c3);输出的是aabc 2020-07-23 …
1:若关于x的多项式-2x2+mx+nx2+5x-1的值与x的值无关,求(x-m)2+n的最小值2: 2020-11-01 …
(2010•永嘉县二模)如图,两个反比例函数y=k1x和y=k2x(其中k1>0>k2)在第一象限内 2020-12-22 …
接触法制硫酸的核心反应是2SO2(g)+O2(g)⇌2SO3(g)△H<0.(1)该反应的平衡常数K 2020-12-31 …
向精通数学排列组合的各位达人求助C0/n+C1/n+C2/n+C3/n……Cn-1/n+Cn/nn属 2021-01-16 …