#include main(){int a=0x7fffffff,b=025;float f1=123.456,f2=2
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/15 20:41:21
#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可能会损失精度.
#include main(){int a=0x7fffffff,b=025;float f1=123.456,f2=2
#include main() { int f,f1,f2,i; f1= 0;f2 =1; printf("%d %d
#include #include main() { float a; int b; a=4.55 ; b=4.5%3;
#include void main( ) { int a=3,b=5; int *p,*q; void f1(int
#include #include main() { int x,y; float m; for(x=0;x
浮点数转换成整数问题#include int main(){float a;int c;a = 9/(float)10;
1-100奇数平均数# include int main(){int i,sum1 = 0,sum2 = 0;float
c语言除法运算问题#include "stdio.h"void main(){int a,b;float c,d;a=3
#include int main() { int x=2,y=3; float i; i=float(x); prin
#include main() { int w; float n,i,r; scanf("%f",&n); w=0; i
#include "stdio.h" main() { int m,n; float k; for (m=6;m>2;m
# include main() { int a=-2,b=0; while(a++&&++b); printf("%d