Question: Write a c++ program to check whether the user input is prime. Any method is accepted except the following for loop: please don't use the

Write a c++ program to check whether the user input is prime.

Any method is accepted except the following for loop: please don't use the code below in your program, similar ideas are allowed.

for(int i = 2; i <= num/2; ++i) { // condition for nonprime number if(num % i == 0) { flag = true; break; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!