Answer to Question #202725 in C++ for SONAM YENTEN

Question #202725

Write a template function that returns the maximum value of three elements passed to the function. Parameters passed to the function can be of int, double, char but all parameters passed are of the same type at point of time. Parameters to be passed to the function as are read as input.


1
Expert's answer
2021-06-03T13:42:02-0400
#include <iostream>


using namespace std;


string maxChar(string a, string b, string c) {
    string mx;
    mx = max(a, b);
    mx = max(mx, c);
    return mx;
}


string a, b, c;


int main()
{
    cin >> a >> b >> c;
    cout << "The maximum is: " << maxChar(a, b, c) << '\n';


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog