Can anyone write the code to find out the maximum of three numbers???? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone write the code to find out the maximum of three numbers????

28th Jul 2018, 9:09 AM
Nguyễn Quang Huy
Nguyễn Quang Huy - avatar
10 Answers
+ 8
Nguyễn Quang Huy You never be able to be a good programmer if you continue this ASK first TRY next trend. I think there's no excuse for you and anyone who knows the basics of the language and has the minimal brainpower to do such assignment, unless you want to prove that you don't have such capability! All folks here are eager to help you properly IF they know that you made your hands dirty, first. Got that?!
28th Jul 2018, 10:45 AM
Babak
Babak - avatar
5th Oct 2018, 7:37 PM
AliR૯za
AliR૯za - avatar
+ 3
yes, but first let us see how much effort you have given to solve it.
28th Jul 2018, 9:22 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 1
Hints : Take 3 input from user. Now use nested if and else to compare these numbers and find largest one and finally print it out. Hope this helps ☺️☺️.
28th Jul 2018, 9:47 AM
Meet Mehta
Meet Mehta - avatar
+ 1
Why not write by yourself?? I think my code is easy enough.
28th Jul 2018, 10:31 AM
Constructor
Constructor - avatar
+ 1
Here's the logic, not writing the whole thing. max = a; if(b>max)max=b; if(c>max)max=c; By the way, I agree you shouldn't come here to have your homework solved by someone else, you should just ask what your logic should be, not the whole code.
28th Jul 2018, 11:22 AM
Alexandru Turculet
Alexandru Turculet - avatar
0
actually i can write it but the code is too long. can you write it shorter??
28th Jul 2018, 9:26 AM
Nguyễn Quang Huy
Nguyễn Quang Huy - avatar
0
template<class T> T getMaxOfThree(const T& a,const T& b,const T& c){return std::max(a,std::max(b,c));} is that what you want?
28th Jul 2018, 10:01 AM
Constructor
Constructor - avatar
0
oh. can you write the whole code
28th Jul 2018, 10:28 AM
Nguyễn Quang Huy
Nguyễn Quang Huy - avatar
0
if (a > b && a > c) { // a is biggest } if (b > a && b > c) { // b is biggest } if (c > a && c > b) { // c is biggest }
28th Jul 2018, 10:58 AM
Azad Ad
Azad Ad - avatar