write a program largest integer functioncpp that defines and

write a program largest integer function.cpp that defines and tests a function largest that takes any three integers and returns the largest integer

Solution

function.cpp

#include <iostream>

using namespace std;
int largest(int a, int b, int c){
if(a>b && a > c){
return a;
}
else{
if(b > c){
return b;
}
else{
return c;
}
}
}

int main()
{
cout<<\"Max value is \"<<largest(4,5,3)<<endl;

return 0;
}

Output:

sh-4.3$ g++ -std=c++11 -o main *.cpp sh-4.3$ main Max value is 5

write a program largest integer function.cpp that defines and tests a function largest that takes any three integers and returns the largest integerSolutionfunc

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site