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

Write a C++ program: A prime number is a number that is only evenly divisible by

ID: 649278 • Letter: W

Question

Write a C++ program:

A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6.

Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise.

Demonstrate the function by writing a complete program. Your program will prompt the user to enter an integer greater than one. It will then use your isPrime function to identify all prime numbers less than or equal to the entered value.

Input Validation: use a function to enter the single value. You may use a variation of the getData function that we developed in class. The error checking should be done in this function, not in main.

Your program must also include comments with your name, the date, and a short description of the project. It must also print this information as a splash screen at the beginning of the program run. You may use any functions that we have developed in the class or others that you want to write yourself in addition to your isPrime function.

Explanation / Answer

#include<iostream>
using namespace std;

bool isPrime(int x)
{
int num,count=0;
num=x;
for(int i=2;i<num;i++)
{
if(num%i==0) // checks if the number is fully divisible or not
{
count++;
}
}
if(count==0)
{
cout<<" Prine no "<<num;
//cout<<count;
return true;
}
else
{

return false;
}

}

void getdata()
{int num;
   cout<<"Enter the number to check : ";
cin>>num;
for(int i=2;i<=num;i++)
{
   bool n=isPrime(i);
  
  
}
  
  
}
int main()

{   // name ------------------------
// this is prime number program get data function is input value that ia for limit the series of prime number
   cout<<"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""";
   cout<<endl;
   cout <<" Prime Number Series Genrate Progam";
   cout<<""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""";";
   cout<<endl;
   cout<<"for prime number bool function using count variable count variable not change if module is not zero that is zero";
  
   cout<<endl;
   getdata();
  


  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote