A prime number is a number that is only evenly divisible by itself and 1. For ex
ID: 3641245 • Letter: A
Question
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 diveded by 1 and 5. The number 6, however, is not prime because it can be divided 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 in a complete program.
Then,
Use the isPrime function in a program that stores a list of all the prime numbers from 1 through 100 in a file.
Explanation / Answer
#include #include using namespace std; bool isPrime(int num) { if(num==1) return false; for(int i=2;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.