After running the following two statements,“int c1 = 1,c2=2,c3; c3=1.0/c2*c1; ”,the value of variable c3 is _________.5 为什么?

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 03:44:33
After running the following two statements,“int c1 = 1,c2=2,c3; c3=1.0/c2*c1; ”,the value of variable c3 is _________.5 为什么?

After running the following two statements,“int c1 = 1,c2=2,c3; c3=1.0/c2*c1; ”,the value of variable c3 is _________.5 为什么?
After running the following two statements,“int c1 = 1,c2=2,c3; c3=1.0/c2*c1; ”,the value of variable c3 is _________.
5 为什么?

After running the following two statements,“int c1 = 1,c2=2,c3; c3=1.0/c2*c1; ”,the value of variable c3 is _________.5 为什么?
C3是1除以C2又乘以C1
1除以C2等于0.5,0.5再乘以C1也就是乘以1,结果还是0.5
这样就得到0.5了啊
这个题是也算是个小经典了,不考虑类型的话答案就是0.5,弱类型的语言应该得出这个结果
如果是像C,C++这种比较严格的强类型语言,是不允许随便转换类型的,结果就会是0