Calling functions

Thanks in advance for any help...very new to c++.

I am having a problem calling a function. the code below is incomplete but the part i am working on is calling findLargest(int& f, int& s) from within the largest().....the function does not seem to get called...it just gets skipped over and then the program goes to system ("pause");

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  #include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

 void	showmenu(void);                  
 void	showhelp(void);
 void	smallest(void);
 void	largest(void);
 void	display(int& f, int& s, int& large);
 void	nums(int& f, int& s);
 int	findLargest(int& f, int& s);  
 char	menuchoice;
 int f,s,large,small;


  int main()		//Main function
{

 
	showmenu();
	cin >> menuchoice;

	switch (menuchoice)
	{
	case 'h':
	case 'H':
		showhelp();
		break;

	case 's':
	case 'S':
		smallest();
		break;

	case 'L':
	case 'l':
		largest();
		break;
	
	case 'q':
	case 'Q':
		cout <<"\n\nThe program will now terminate \n\n\n\n\n\t\t\t\t\t\t";
		system ("pause");
		return 0;

	default:
		cout << "That is not a valid entry, please try again \n\n\n\n\n\t\t\t\t\t\t";
		system ("pause");
		system ("cls");
		main();
	}
		
		
		
		return 0;
 }

	void showmenu()
	
	{
		cout << "\n\n\t\tPlease select a menu Item, then hit enter\n\n" << endl;			//displays menu
		cout << "\t\tHelp\t   Smallest\tLargest\t      Quit" << endl;  
	
		return ;
	}
			
	void showhelp()
	{
		system ("cls");
		cout << "Press H or h to bring up this Help screen\n\n"
				"Press S or s to be prompted to input 2 integers.\n"
				"the program will determine the smallest of the integers\n"
				"and return how many numbers were positive, negative and zeros.\n\n"
				"Press L or l and the program will determine the Largest of the integers\n"
				"and return how many numbers were positive, negative and zeros.\n\n"
				"Press Q or q to quit this program"
				"\n\n\t\t\t\t\t";
		system ("pause");
		system ("cls");
			main();
		
		
		
		
		
		
		
		system ("pause");
	}
		
	void largest()

	{
		cout <<"please enter the first integer ==> ";
		cin >> f;
		cout <<"please enter the second integer ==> ";
		cin >> s;

		int findLargest(int& f, int& s);
		
		//void display(int& f, int& s, int & large);
	
	system ("pause");
	
	}

	void smallest ()

	{

	}

	void display(int& f, int& s, int& large)

	{
	cout << "n1 = "; cout << f; cout <<", n2 = "; cout << s; cout << " and the larget number is: "; cout << large; 
	return;
	}

	void nums(int f, int s)
	
	{

	}

	int  findLargest(int& f, int& s)
		
	{
	
	
		if (f >= s)
			large = f;
		else 
			large = s;
			return large;
	}
Line 101 int findLargest(int& f, int& s); should be int num = findLargest(f, s);
Last edited on
Topic archived. No new replies allowed.