1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include <iostream>
using namespace std;
void get_value (int &a, int &b, int &c, int &d, int &e);
void find_largest (int a, int b, int c, int d, int e, int &largest);
void print_largest (int largest);
int main ()
{
int a, b, c, d, e, largest;
get_value ( a, b, c, d, e);
find_largest (a, b, c, d, e, largest);
print_largest ( largest);
return 0;
}
void get_value (int &a, int &b, int &c, int &d, int &e)
{
cout << "Enter the value for A: " << endl;
cin >> a;
cout << "Enter the value for B: " << endl;
cin >> b;
cout << "Enter the value for C: " << endl;
cin >> c;
cout << "Enter the value for D: " << endl;
cin >> d;
cout << "Enter the value for E: " << endl;
cin >> e;
}
void find_largest (int a, int b, int c, int d, int e, int &largest)
{
largest == a;
if (b > a)
{
largest = b;
}
else if (c > b)
{
largest = c;
}
else if (d > c)
{
largest = d;
}
else if (e > d)
{
largest = e;
}
}
void print_largest (int largest)
{
cout << "The largest of the five numbers is: " << largest << endl;
}
|