Answer to Question #233992 in C++ for Brie

Question #233992
Write a function that compares three integer parameters and returns the largest .Define your function after the main() function .Demonstrate that your function works correctly by creating at least one Animal object , and calling all the methods defined for the animal class
1
Expert's answer
2021-09-07T14:16:34-0400
#include <iostream>
#include <string>


using namespace std;




class Animal 
{


public:
	int largestValue(int i,int j,int k){
		return i > j? (i > k? i: k): (j > k? j: k);
	}
};




int main()
{
	Animal animal;
	cout<<"4,5,6\n";
	cout<<"The largest value is: "<<animal.largestValue(4,5,6)<<"\n";


	cout<<"8,1,2\n";
	cout<<"The largest value is: "<<animal.largestValue(8,1,2)<<"\n";


	cout<<"2,10,2\n";
	cout<<"The largest value is: "<<animal.largestValue(2,10,2)<<"\n";


	int pause;
	cin>>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
APPROVED BY CLIENTS