PROBLEM 59
Medium

Maximum of Three

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#59

Given three integers `a`, `b`, and `c`, print the maximum value.

EXAMPLE

Example

Input
1 2 3
Output
3

LIMITS

Constraints

|a|, |b|, |c| ≤ 10^9.
📖
LEARN Theory for this problem
+

An `if` / `else if` / `else` chain checks alternatives from top to bottom. Put more specific or higher-priority conditions first.

Connection to “Maximum of Three”: here, intermediate values are best kept in named variables so the formula stays readable and data types remain clear.

💡
NEED HELP? Hints
+

['List the possible cases and make them mutually exclusive.', 'After solving “Maximum of Three”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    cout << max(a, max(b, c)) << '\n';
    return 0;
}