I am having trouble with this simple program to display three numbers entered from highest, medium, lowest. Specifically, with the ouput_result void function. Stuck, and not sure what I am doing wrong. Fairly new to C++, this is my first course in C++. Any help would be appreciated.
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
void get_user_input(int & a, int & b, int & c);
void output_result (int a, int b, int c);
int larger(int a , int b);
int largestOfThree(int a, int b, int c);
int medium (int a, int b);
int middleOfThree (int a, int b, int c);
int smaller (int a , int b);
int smallestOfThree (int a, int b, int c);
int main(int argc, char *argv[])
{
int a, b, c;
get_user_input(a, b, c);
output_result ('largst', a, b, c);
output_result ('medium', a, b, c);
output_result ('smallest', a, b, c);
system("PAUSE");
return EXIT_SUCCESS;
}
void get_user_input(int & a, int & b, int & c)
{
cout << "Please enter three numbers:";
cin >> a >> b >> c;
}
void output_result(string task, int a, int b, int c)
{
if (task == "largest") cout << "The largest number is "" <<endl;
if (task == "medium") cout << "The medium number is "" <<endl;
if (task == "smallest") cout << "The smallest number is "" <<endl;
}
int largestOfThree(int a, int b, int c)
{
return larger(a, larger(b, c));
}
int larger(int a , int b)
{
if (a >= b)
return a;
else
return b;
}
int smallestOfThree (int a, int b, int c)
{
return smaller(a, smaller (b, c));
}
int smaller (int a, int b)
{
if (a <= b)
return a;
else
return b;
}
int middleOfThree(int a, int b, int c)
{
if ( a <= b && a >= c)
return a;
else
if (a <= c && a >= b)
return a;
if ( b <= a && b >= c )
return b;
else
if (b <= c && b >= a)
return b;
if ( c <= a && c >= b)
return c;
else
if ( c <= b && c >= a)
return c;
}
}