+ 1
Can anyone write the code to find out the maximum of three numbers????
10 Antworten
+ 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?!
+ 5
https://code.sololearn.com/cNH72y47v3Vq/?ref=app
it's for n number
+ 3
yes, but first let us see how much effort you have given to solve it.
+ 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 ☺️☺️.
+ 1
Why not write by yourself??
I think my code is easy enough.
+ 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.
0
actually i can write it but the code is too long. can you write it shorter??
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?
0
oh. can you write the whole code
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
}