+ 1

Why is float x= 11/100 ; in c++ only showing 0 ?

C++ question

30th Aug 2022, 6:32 PM
Emediong Ekoh
Emediong Ekoh - avatar
2 Respuestas
+ 5
11 and 100 are both integers. Dividing 2 integers will have an integer as result. You could try float x = (float)11/100; or float x = 11/100.0; so at least one of the numbers is a decimal number.
30th Aug 2022, 6:38 PM
Lisa
Lisa - avatar
+ 4
11 divisable by 100 zero times. ... int/int result int value only.. .
30th Aug 2022, 6:34 PM
Jayakrishna 🇮🇳