+ 2

How?

I was in a chellenge and i found out that my answer was wrong.. but it seemed right... double x = -8/5; cout<<x; What will be the answer? . . . . . . . . . . . . . . . . . . . . . Answer is -1 but how?

17th Nov 2019, 6:47 AM
Hasham Meher
Hasham Meher - avatar
1 Answer
+ 6
Answer is definitely -1 as it's division of 2 integers getting stored in double x..... -8/5 is -1 cause -8, 5 both are ints... If u need expected results.... Use.. -8/5.0 or (double) -8/5
17th Nov 2019, 7:27 AM
Saurabh B
Saurabh B - avatar