0
why the output of float a=1/2; is 0?
2 ответов
+ 4
Because 1 and 2 are integer values so it gives an integer output. You need to typecast it to get a float output. For eg-
float a = (float) 1/2; OR
float a = 1.0f/2.0f;
+ 4
or simply float a = 1/2.0; will do