Back to School

In our school days, all of us have enjoyed the Games period. Raghav loves to play cricket and is Captain of his team. He always wanted to win all cricket matches. But only one last Games period is left in school now. After that, he will pass out from school.

So, this match is very important to him. He does not want to lose it. So he has done a lot of planning to make sure his team wins. He is worried about only one opponent - Jatin, who is a very good batsman.

Raghav has figured out 3 types of bowling techniques, that could be most beneficial for dismissing Jatin. He has given points to each of the 3 techniques.

You need to tell him which is the maximum point value so that Raghav can select the best technique.

3 numbers are given in input. Output the maximum of these numbers.

Example:

Input:  a = 8, b = 6, c= 1
Output: 8

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int maxThree(int aint bint c)
{
    if (a >= b && a >= c)
        return a;
    if (b >= a && b >= c)
        return b;
    return c;
}
int main()
{
    int a = 8b = 6c = 1;

    cout << maxThree(abc);

    return 0;
}


No comments:

Post a Comment