posted 24 years ago
Hi,
Here is a question from Marcus
Which of the following are legal statements?
1) float f=1/3;
2) int i=1/3;
3) float f=1.01;
4) double d=999d;
The correct answer is 1,2,4.
I compiled & got it correct too.But i have a small doubt.When u say float f=1/3,why does'nt it consider 1/3 which 0.3333 as double.We know that the default type for decimal type is double.Why does'nt it give an error for No.2 option too?I have the same doubt here.Can anyone please make it clear for me?
Thanks