0

any idea

double a=4.0; double b=4.0; double r=a+b; cout>>r; the answer will be 8 how to get it as 8.0

28th Aug 2016, 3:04 PM
Rahul Suresh
Rahul Suresh - avatar
6 Réponses
+ 1
for this you dont need double...use float
28th Aug 2016, 5:09 PM
Carlos Augusto Silva Gurgel
Carlos Augusto Silva Gurgel - avatar
+ 1
or use double a = 4.0f; double b = 4.0f; double r = a + b; using f after the number to warrant that will be a floating point number...
29th Aug 2016, 2:39 AM
Carlos Augusto Silva Gurgel
Carlos Augusto Silva Gurgel - avatar
+ 1
double a = 4.0; double b = 4.0; double r = a+b; cout << (float)r;
3rd Sep 2016, 11:33 PM
Davood Abdollahi
Davood Abdollahi - avatar
0
tnk u ...
29th Aug 2016, 1:12 PM
Rahul Suresh
Rahul Suresh - avatar
0
oops still it's 8 😑
29th Aug 2016, 1:22 PM
Rahul Suresh
Rahul Suresh - avatar
0
Xddddddd
31st Aug 2016, 11:55 AM
Jacob Ross
Jacob Ross - avatar