Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ Write a program called IsPrime.cpp that generates a list of all prime numbers from 1 to 100 (inclusive). In your program, implement a function
c++
Write a program called IsPrime.cpp that generates a list of all prime numbers from 1 to 100 (inclusive). In your program, implement a function isPrime () that returns a Boolean value to indicate whether or not an input number is prime. Remember that 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 divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6 The program MUST contain the following features: A function isPrime (int num) that returns a Boolean value of true if num is a prime number or false if num is not a prime number. In main(), you must use your isPrime () function to generate a list of all prime numbers between 0 and 100 (inclusive) Hint: The mod operator (%) will tell you whether a number is evenly divisible by another number! A sample run of the program is shown below. The prime numbers between 1 and 100 are: 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 Press any key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started