different options

I wrote a program to do different calculations.I wrote it so that everytime a user enters a choice,it does a different calculation.After the user finishes its supposed to give the user a choice to enter another choice or zero to finish.Im having trouble getting it to go to another option.I have a feeling my problem involves the brackets with my if statements. If anybody can help,id appreciate it.
Note:this is just the main of the program,the rest of it is just the various functions for the calculations.
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
int main()
{
	//ofstream outf("f://output.txt",ios::out);
     int choice;
	 cout<<"Enter a number between 1 and 5: ";
	 cin>>choice;
	 if (choice==1)
	 {
	cout<<"This calculates GCD"<<endl; 
     cout << "A: ";
     cin >> a;
     cout << "N: ";
     cin >> n;
	 cout << "GCD ("<<a<<","<<n<<")="<< gcd(a,n) << endl;
	 cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
	 cin>>choice;
	 }
	 else if(choice==2)
	 {
		 cout<<"This calculates Extended euclid"<<endl;
		 cout << "A: ";
		 cin >> a;
		 cout << "N: ";
		 cin >> n;
		  extendedeuclid(a,n);
		  cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
	 cin>>choice;
	 }
	 else if(choice==3)
	 {
	cout<<"This calculates MODULAR-LINEAR-EQUATION-SOLVER"<<endl;
	cout << "A: ";
		 cin >> a;
		 cout << "N: ";
		 cin >> n;
	 cout<<"b:"<<endl;
	 cin>>b;
	 cout<<"Number of solutions:"<<modularlinear(a,b,n)<<endl;
	 cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
	 cin>>choice;
	 }
	 else if(choice==4)
	 {
	cout<<"This calculates MODULAR-EXPONENTIATION"<<endl;
	 cout<<"m: "<<endl;
	 cin>>m;
	 cout<<"e: "<<endl;
	 cin>>e;
	 cout<<"n : "<<endl;
	 cin>>n;
	 cout<<"M^e (mod n) = "<<mod_pow(m,e,n)<<endl;
	 cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
	 cin>>choice;
	 }
	 else if(choice==5)
	 {
	cout<<"This finds the RSA Keys"<<endl;
	 cout<<"p:"<<endl;
	 cin>>p;
	 cout<<"q:"<<endl;
	 cin>>q;
	 cout<<"e:"<<endl;
	 cin>>e;
	rsa(p,q,e); 
	cout<<"Enter a number between 1 and 5 or 0 to end the program"<<endl;
	 cin>>choice;
	 }
	 else if (choice==0)
	 {	
		 cout<<"Program Completed"<<endl;
	 }
		 system("pause");
	 return 0;
}

hi,
To make your code repeat you would need something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

    bool    done = false;
    char    result;

    while(!done)
    {
        // Repeatable code here
      

        cout << "Are you finished";
        cin >> result;

        if (result == 'n' || result == 'N')
        {
              done = true;
        }

    }
Topic archived. No new replies allowed.