0
Why this code does not give output 2.5
this code is giving output 2.0 instead of 2.5 what's wrong? https://code.sololearn.com/crU2duqvE5dD/?ref=app
10 Answers
+ 2
I think because you divide two integers, the answer will be 2. But you specified that it should return a double so it makes it a double by adding the decimal -> 2.0
+ 2
Here's what you wanted
https://code.sololearn.com/cGV160V15o6q/?ref=app
+ 1
Dhruvil Prajapati yes. If you divide 2 integers it will automatically convert the result to an integer
+ 1
Dhruvil Prajapati no problem!
+ 1
The answer is a double, not an integer. You can input two integers and retur a double, the answer will be different though.
0
the 2 parameters in your div() function should be 2 doubles
0
is it necessary that to take double as a output you have to divide two double inputs???
0
okay i get that...
thank you
0
answer is double because x is declared as a double...answer should be 2.5...
0
i tried that, it gives me answer.
but i am supposing that dividing two integer should have to give me a double number bcoz i have saved that value in double.
Anyway now i know that it's not possible...
thanks for your efforts..