- 1
Does the following code works if the variables are float or double?
Does the following code works if the variables are float or double? int greatest(float a, int b, int c) { (a >= b && a >= c) { return a; } if (b >= a && b >= c) { return b; } else { return c; } }
6 odpowiedzi
0
why not?
0
is this c++??s sure the code won't work if it's like this!
0
(a >= b && a >=
) { what are you trying to compare here?
and return ; is empty and won't return anything in the else statement!
0
you are right, I corrected that.
0
(a >= b && a >= c) ??? nothing happens here it should be if (a >= b && a >=
c) . also why do you want to compare a float with int why not making all the variables int ?
0
also why making a function for that just do it in the main() section!
example:
int a=10;
int b=5;
int c=9;
{
if(a >= b && a >=c)
{
cout<< a;
}
else if (b >= a && b >= c)
{
cout<< b;
}
else
{
cout<< c;
}
}
}
////
also you can make it work with both!