Ask Question
24 November, 01:24

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

+4
Answers (1)
  1. 24 November, 01:51
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers