+ 1
Why the output is 7.8 though "a" and "b" is integer ... I think a=5 b=7 and the function return m =7
#include <iostream> using namespace std; int max(int a,int b) { int m; if (a<b) m= b; else m= a; return m; } int main() { double x=5.6 ,y=7.8; cout<<max(x,y); return 0; }
3 Respostas
+ 4
The output is 7 with no doubt, since you cast it to int implicitly.
+ 4
I've gotten these results and I think it's up to compiler on how to deal with implicit type casting.
MS Visual C++ ==> 7
C4Droid. ====> 7.8
SoloLearn compiler ==> 7.8
online codeChef =====> 7.8
online webCompile ===> conversation from double to int warning
online ideOne =======> 7.8
The only exception here is MS VC++ that shows what we are expected. C4droid and others use gcc, g++, and clang
+ 2
@Babak
thank you ....🌼🌼