Question: C++ #include #include #include using namespace std; Write a program called primes: 1. Write a boolean function: bool isPrime(integer n). Returns true if prime; false
C++
#include#include #include using namespace std; Write a program called primes: 1. Write a boolean function: bool isPrime(integer n). Returns true if prime; false if not prime. 2. Write in main() 3. Declare a vector lst: vector primes_list; 4. Write an infinite loop: 5. Inside the loop, ask the use to enter a poisitive integer num 6. Read the positive integer num. 7. Call isPrime function for all the numbers from 1 to num, inclusively. 8. Store all the primes in primes_list as follows: primes_list.push_back(i); 9. Ask the user if they want to continue and read a new number. 10. Outside the loop, print all the prime numbers. Use any or all of these methods: for (int val : primes_list) cout << val << " "; cout << endl; for (int i = 0; i < primes_list.size(); i++) cout << primes_list[i] << " "; cout << endl; for (auto i = primes_list.begin(); i != primes_list.end(); ++i) cout << *i << " "; cout << endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
