The entire program ends after int main(), but I want it to continue forward to the max/min functions...
#include <iostream>
using namespace std;
int a, b, c;
int main ()
{
a = 0;
b = 0;
c = 0;
cout << "Please enter three integers." << endl;
cout << "Integer one: " << endl;
cin >> a;
cout << "Integer two: " << endl;
cin >> b;
cout << "Integer three: " << endl;
cin >> c;
cout << "Your three input values were: " << a << ", " << b << ", and " << c << "." << endl;
return (a, b, c);
}
int maxofthree (int a, int b, int c)
{
if (a > b)
if (c > a)
cout << "The largest value is " << c << "." << endl;
else
cout << "The largest value is " << a << "." << endl;
if (b > a)
if (c > b)
cout << "The largest value is " << c << "." << endl;
else
cout << "The largest value is " << b << "." << endl;
return (a, b, c);
}
int minofthree (int a, int b, int c)
{
if (a < b)
if (c < a)
cout << "The smallest value is " << c << "." << endl;
else
cout << "The smallest value is " << a << "." << endl;
if (b < a)
if (c < b)
cout << "The smallest value is " << c << "." << endl;
else
cout << "The smallest value is " << b << "." << endl;
return 0;
}
Question
Ravager
The entire program ends after int main(), but I want it to continue forward to the max/min functions...
#include <iostream> using namespace std; int a, b, c; int main () { a = 0; b = 0; c = 0; cout << "Please enter three integers." << endl; cout << "Integer one: " << endl; cin >> a; cout << "Integer two: " << endl; cin >> b; cout << "Integer three: " << endl; cin >> c; cout << "Your three input values were: " << a << ", " << b << ", and " << c << "." << endl; return (a, b, c); } int maxofthree (int a, int b, int c) { if (a > b) if (c > a) cout << "The largest value is " << c << "." << endl; else cout << "The largest value is " << a << "." << endl; if (b > a) if (c > b) cout << "The largest value is " << c << "." << endl; else cout << "The largest value is " << b << "." << endl; return (a, b, c); } int minofthree (int a, int b, int c) { if (a < b) if (c < a) cout << "The smallest value is " << c << "." << endl; else cout << "The smallest value is " << a << "." << endl; if (b < a) if (c < b) cout << "The smallest value is " << c << "." << endl; else cout << "The smallest value is " << b << "." << endl; return 0; }Link to comment
Share on other sites
16 answers to this question
Recommended Posts