Maximum & minimum in c++ | Sololearn: Learn to code for FREE!

0

Maximum & minimum in c++

Can anyone help to find maximum and minimum between 4numbers in c++, with just using if/else? It goes like this: user enters 4 numbers and I have to give the user maximum and minimum numbers back. I appreciate it :))

c++

3/7/2021 1:54:58 PM

Sahaarr

9 Answers

New Answer

+10

http://www.cplusplus.com/reference/algorithm/max/ https://code.sololearn.com/c7g8VgG06mp9/?ref=app https://code.sololearn.com/cwyxWi2ou6wB/?ref=app

+5

https://en.cppreference.com/w/cpp/algorithm/minmax_element if you use a container, like vector, you can use this stl library function

+4

Martin Taylor https://code.sololearn.com/c8HhYED6lgxv/?ref=app seems to work with runtime values too

+3

https://code.sololearn.com/cB2v8AMiwDu6/?ref=app https://code.sololearn.com/ce1nKe3z63Gu/?ref=app hope this helps

+3

Then even more simple is to shove an initializer list to std:: min or max https://code.sololearn.com/cVTzJWzaj54B/?ref=app

+1

#define CPP ChillPill Martin Taylor Sharique Khan thank you so much!