Answer to Question #293127 in C++ for sfk

Question #293127

Create a function Maximum using templates, your function should have the following prototype

t Maximum (t x, t y)

This function should return the maximum values out of the two values being passed, in your main function create variables of different types, integer, character and double and check what your function returns for each different variable type. 


1
Expert's answer
2022-02-02T06:11:04-0500
#include <iostream>
#include <string>
using namespace std;


template<typename t>
t Maximum (t x, t y){
	if(x>y){
		return x;
	}
	return y;
}




int main(){
	cout<<"Maximum(4,6): "<<Maximum(4,6)<<"\n";
	cout<<"Maximum(n,a): "<<Maximum('n','a')<<"\n";
	cout<<"Maximum(45.65,25.6): "<<Maximum(45.65,25.6)<<"\n";


	system("pause");
	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