Basic function question

I have been racking my brain, my textbook and the internet.

I cannot get the program to output anything other than 0;

I want to learn, so just point me in the right direction.

Thanks.


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
#include <iostream>
#include <cmath>

using std::cin;
using std::cout;

int maximal(int);

int main()
{
	int n;
	int max = 0;
	cout << "Please enter three numbers: ";
	max = maximal(n);
	cout << "The maximal value is: " << max << "\n";
	return 0;
}

int maximal(int n)
{
	int maxsf = 0;
	int i = 0;
	int size = 3;
	while( i < size)	
	{
	cin >> n;
	if(n > maxsf)
 	{
	maxsf = n;
	}
	i++;
	}
	n = maxsf;	
}

you arent returning anything from your function.

1
2
3
4
5
6
7
{
......


return n;
}
Last edited on
Thank you so much.
Topic archived. No new replies allowed.