+ 1

A challenge: Make a function that can take a double and an int as its arguments,and returns the biggest number.

(returns an int if the int is the biggest number,else returns the double),also don't include any file or create the main function.(a 2 lines code).

5th Sep 2016, 11:22 AM
Asrk
Asrk - avatar
4 odpowiedzi
+ 2
double max(double d, int i) { return (d > i ? d : i); }
5th Sep 2016, 1:49 PM
Zen
Zen - avatar
+ 2
AFAIK, that's not possible in c++, or any language with strong typing.
5th Sep 2016, 5:13 PM
Zen
Zen - avatar
0
Your function returns always double.It should have possibility to return an int or double.
5th Sep 2016, 1:53 PM
Asrk
Asrk - avatar
0
use tuple
6th Sep 2016, 2:03 AM
Chantastic Nyan-Nyan
Chantastic Nyan-Nyan - avatar