Ask Question
20 May, 21:14

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);

+2
Answers (1)
  1. 20 May, 22:43
    0
    Just include all the following data accurately.

    #include

    #include

    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
    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
    if (n%i==0)

    return false;

    return true;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers