Min, Max and Median Project Help

I am new to c++ and need to write a program to get three integers from the user and outputs the Min, Max and Median. The catch is that, they all need to be different functions. I am a bit confused right now and don't know how to go further. Any help would much appreciated.

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
66
67
68
69
70
71
72
73
#include "stdafx.h"
#include <iostream>

using namespace std;

int  GetInteger();
int  Max(int, int, int, int);
int  Min();
int  Middle();
void Print(int, int, int, int);


int main()
{
	
	int n1, n2, n3 = 0;
	int max, min, middle;

	n1 = GetInteger();
	n2 = GetInteger();
	n3 = GetInteger();



    return 0;
}




int Max(int p1, int p2, int p3, int max) {

	int max;
	
	max = p1;

	if (p2 > p2)
		max = p2;

	if (p3 > max)
		max = p3;

	return max;

	}//  Function Max()
//  ===================

void Print(int min, int middle, int max) {

	cout << endl;
	cout << "Min Value    ==> " << min << endl;
	cout << "Middle Value ==> " << middle << endl;
	cout << "Max Value    ==> " << max << endl;




	}//  Function Print()
//  =====================

int GetInteger() {

	int intValue;

	cout << "Enter an three integers ==> ";
	cin >> intValue;

	return intValue;

	}//  GetInteger()
//  =================

Last edited on
It seems like the main program could look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
	int n1, n2, n3 = 0; // what are values of n1 and n2 now?
	n1 = GetInteger();
	n2 = GetInteger();
	n3 = GetInteger();

	int min = Min( n1, n2, n3 );
	// other function calls ...

	Print( min, middle, max );
	return 0;
}

Min, Max and Middle should probably follow the same pattern of "take three numbers and return one".


Your Print() on lines 48-58 seems fine. Declaration on line 10 is for some other Print().

Line 65: What three? This function reads exactly one integer.


What is the 'max' on line 35? Is it the "int max" from line 33, or the "int max" from line 31?
Topic archived. No new replies allowed.