Use the isprime function that you wrote in programming challenge 21 in a program that reads in an integer that is less than 3001 stores a list of all the prime numbers from 2 through that number in a file name d "primelist.txt". prompts and output labels. no prompts, no labels. after closing the file, the program writes "prime numbers written to primelist.txt." on a line by itself in standard output . input validation if the value read in exceeds 3000, the program silently terminates. // function prototype bool isprime(int);

Respuesta :

Just include all the following data accurately. 
#include <iostream>
#include <fstream>
using namespace std;

bool isPrime(int);

int main()
{
int num=0;
int i;
bool prime;

ofstream outFile;
outFile.open("PrimeList.txt");

while (num == 0 )
{
cin >> num;
}

for(i=2;i<num;i++)
if(isPrime(i))
outFile << i << "\n";

cout << "Prime numbers written to PrimeList.txt.
\n";
outFile.close();
return 0;
}
bool isPrime(int n)
{
int i;
for(i=2;i<n-1;i++)
if(n%i==0)
 return false;
return true; 
}