Need help with code

This is a math tutor program. I am having an issue when I enter -1 to exit to the main menu it is not working. any help will be 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  // This program is a math tutor
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;

void getMenu (int &);
void addition (int, int);

void getRandon ( int &, int &);

int main()
{
    int num1, num2;
	int choice;
	 
	
	getMenu(choice);
	
	
	do
	{
		getRandon (num1, num2);
		
		switch (choice)
		{
			case 1: addition(num1,num2); 
				break;	
		}

    } while (choice != 6);
        
	return 0;
}


void getMenu(int &rchoice)
{
    
    
	cout << "Menu \n\n"
		<< "1. Addition \n"
		<< "2. Subtraction \n"
		<< "3. Multiplication \n"
		<< "4. Division \n"
		<< "5. Modulus \n"
		<< "6. Quit \n\n"
		<< "Enter your choice: ";
	cin >> rchoice;
		while (rchoice < 1 || rchoice > 6)
		{
			cout << "Enter a choice in the range of 1 - 6: \n";
			cin >> rchoice;
		}
}

void addition (int n1, int n2)
{
    int answer;
	int countCorrect = 0;
	int countIncorrect = 0;

	//do
	//{

		cout << "What is " << n1 << " + " << n2 << endl;
		cout << "Enter your answer or (-1 to return to the menu.)\n";
		cin >> answer;
		if (answer != -1)
		{
		if (answer != n1 + n2)
		{
			cout << "No. Try again!\n";
			cin >> answer;
		}

		else 
		{
			cout << "Very Good \n";
		}
		}
	//} while (answer != -1);
}

void getRandon (int &rNum1, int &rNum2)
{
    
    srand(time(0));
    rNum1 = 1 + rand() % 50;
    rNum2 = 1 + rand() % 50;
        
}
Topic archived. No new replies allowed.