Trouble with functions (calling and previews)

I'm new to functions and having a lot of trouble. When I run the program I get the error " 'golf': must return a value" but it doesn't prompt the user for any input or anything.

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
  //Author Henry Jones
//Course: COSC1436
//Program Assignment 4 - Golf
//References: C++ Website && StackExchange && Reddit

#include <iostream>
#include <iomanip>
using namespace std;

int golf (int strokes, int par)
{
	cout << "Enter par for the hole (3-5): ";
	cin >> par;

	while (par < 3 || par > 5)
	{
		cout << "ERROR: PAR MUST BE BETWEEN 3 and 5\n";
		cin >> par;
	}

	cout << "Enter number of strokes (1-10): ";
	cin >> strokes;



	if (strokes == 1)
	{
		cout << "Score: hole-in-one\n";
	}
	else if (strokes == par - 3)
	{
		cout << "Score: double-eagle\n";
	}
	else if (strokes == par + 1)
	{
		cout << "Score: Bogey \n";
	}
	else if (strokes == par + 2)
	{
		cout << "Score: Doublee bogey\n";
	}
	else if (strokes == par + 3)
	{
		cout << "Score: Trible bogey\n";
	}
	else if (strokes == par + 4)
	{
		cout << "Score: four-over-par\n";

	}
	else if (strokes == par + 5)
	{
		cout << "Score: five-over-par\n";

	}
	else if (strokes == par + 6)
	{
		cout << "Score: six-over-par\n";

	}
	else if (strokes == par + 7)
	{
		cout << "Score: seven-over-par\n";

	}
}


Then I need to have a function call it after I prompt the user if the program should be repeated. But I don't know how to work with that.

Thanks in advance.
When I run the program I get the error " 'golf': must return a value"

When you attempt to compile the program you get the error.

You promise to return a value in golf. You don't. Either do so or stop promising to return a value.

1
2
3
4
  -- "I promise to return a value of type int"
 |
 v
int golf (int strokes, int par)
Thanks! I figured out I needed to change it to void instead of int?
Topic archived. No new replies allowed.