+ 1

if c=float a/int b, should i declare c as float or int?

26th Oct 2017, 4:01 AM
Siti Nor Amirah Binti Mustaffa
Siti Nor Amirah Binti Mustaffa - avatar
4 Respuestas
+ 5
It depends of what you want it to be. You can declare c as both but as @Cool Codin said, the type of a/b will be float so if c is int, the result will be rounded
26th Oct 2017, 6:12 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
You should declare 'c' as 'float' as float a will force convert int b to float, this is called type casting. 😊😊
26th Oct 2017, 4:10 AM
Cool Codin
Cool Codin - avatar
+ 1
okayy thank u 😊
26th Oct 2017, 6:42 AM
Siti Nor Amirah Binti Mustaffa
Siti Nor Amirah Binti Mustaffa - avatar