Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a C++ program that allows the user to input a positive integer u

ID: 646020 • Letter: I

Question

I need to write a C++ program that allows the user to input a positive integer until a zero is input (the zero would end the function). After each integer is input, a function is called to determine if the last integer input was a prime number. Main() should output the values tested for whether it was prime as not.

The prompts would be as follows

Please input a positive number or zero to exit the program

7 - the value is prime

Please input a positive integer or zero to exit the program

50 - the value is not prime

Please input a positive integer or zero to exit the program

20 - the value is not prime

Please input a positive integer or zero to exit the program

0 - Goodbye!

Please help :~D It's appreciated

Explanation / Answer

#include<stdio.h>
#include<math.h>

using namespace chegg

public class prime
{
    public int test_prime(int n)
    {
     int count=0;
     
     for(int i=2;i<n;i++)      

         {
            if(n%i==0)       // checks if the number is fully divisible or not
             {
               count++;
             }
         }
     return (count);
    }

void main()
{
int num,cnt;
do
{
cout>>"Please input a positive number or zero to exit the program";
cin<<num;
   cnt=test_prime(num);
   if(cnt==0)
   {
   cout<<num<<"- the value is prime";
   }
   else
     {
   cout<<num<<"- the value is not prime";
     }
   }while(num!==0)
    if(num==0)
   cout>>"Goodbye!"
        return(1);
}