Returning to menu



...
Last edited on
where is the rest of the program?
and please use code brackets.
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
#include <iostream>

using namespace std;

int main()
{
int number;
int option;
int helper = 0;
do
{
cout << "Cool Configurations: Primality and Factorization\n";
cout << "You can use this program in order to test a integer for primality and/or to find the factors of your chosen integer.\n";

cout << "Menu\n";
cout << "1) Choose option '1' if you would like to determine the primality of your number\n";
cout << "2) Choose option '2' if you would like to factor your number\n";
cout << "3) Choose option '3' if you would like to Exit this Program\n";

cout << "Please enter your chosen option from the above menu.\n";
cin >> option;

if (option == 1)
{
cout << "Please enter a positive integer.\n";
cin >> number;
cout << " Your number is " << number << ".\n";

if (number == 1)
{
cout << "One is not a prime number.\n";
}

else if (number == 2)
{
cout << "Two is totally a prime number!\n";
}

else if (number >= 3)
{
for (int p = 2; p*p <= number; p++)
{
if (number % p == 0)
{
helper = helper + 1;
}
}
if (helper == 0)
{
cout << "This is most definitely a prime number!!!\n";
}
else
{
cout << "This in unfortunately not a prime number!!!\n";

}
}
}

else if (option == 2){
return 0;
}
}while(option!=3)
}
Last edited on
I apologize it did not copy and paste correctly.
the code is still incomplete.
Topic archived. No new replies allowed.