Question: C++ problem, how can I use continue, do & break in the following code. I would like to add this question: Would you like to
C++ problem, how can I use continue, do & break in the following code. I would like to add this question: "Would you like to try another number ? (Yes =1 / No =0)" if 1, the program will ask for another number, if no, it will break
#include
using namespace std;
int main() {
int n, i, x;
bool isPrime = true;
cout
cin >> n;
for(i = 2; i
{
if(n % i == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
cout
else
cout
return 0;
}

Question #1: write a program that determines whether a number is prime or not. Use recursion to implement this behavior. The program should validate all input. Input a positive number: 3 Is number 3 prime?: Yes Would you like to try another number? (Yes 1/ No -8):1 Input a positive number: 6 Is number 3 prime?: No Mould you like to try another nuaber? (Yes 1/ No Would you like to try another number? (Yes = 1 / No = 0): 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
