169k views
2 votes
Write a programme with C++ language wich print the biggest number in between three numbers , whith INT

1 Answer

7 votes
Your question is a bit misleading, I'm having trouble understanding what you mean with "in between". I'm assuming you want the biggest number from an input of 3 numbers. You did not specify what should happen if more than one number is the biggest (ie., they're equal).

A very naive implementation might be:

void PrintBiggest(int a, int b, int c)
{
if ((a >= b) && (a >= c)) cout << a;
else if ((b >= a) && (b >= c)) cout << b;
else if ((c >= a) && (c >= b)) cout << c;
}

If you want to use STL (mine is a little rusty), the following could be the start of something more generic:

void PrintBiggest(int a, int b, int c)
{
std::vector<int> myints;
myints.push_back(a);
myints.push_back(b);
myints.push_back(c);
sort(myints.begin(), myints.end());
cout << myints.back();
}



User Broly
by
7.5k points