Write a C++ program that allows the user to enter positive integers unitil zero
ID: 646006 • Letter: W
Question
Write a C++ program that allows the user to enter positive integers unitil zero is input. After each integer is input a function is called to determine if the last integer input was a prime number. Main() should output the value teste whether it was a prime or not?
Example run:
please input a positive integer or zero to exist the program
5 the value is prime
please input a positive integer or zero to exist the program
40 the value is not prime
please input a positive integer or zero to exist the program
15 the value is not prime
please input a positive integer or zero to exist the program
0 thanks for playing - goodbye
Explanation / Answer
#include #include using namespace std; int main() { int number; do{ cout number; if((number%2==0) ||(number%3==0) || (number%4==0)||(number%5==0)||(number%6==0)|| (number%7==0)||(number%8==0)||(number%9==0)) coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.