Question: Write a complete C++ program that is made of three functions main(), primeSum(), and bePrime(). The skeleton of these functions are shown below. //Judge if
Write a complete C++ program that is made of three functions main(), primeSum(), and bePrime().
The skeleton of these functions are shown below. //Judge if n is a prime number and return the Boolean result to caller bool bePrime(int n) { Use a loop, better with a logical variable }
//return the sum of all prime numbers less than m int primeSum(int m) { // for loop to traverse all integers from 2 to m // Call bePrime() in the loop body, preferably using an if statement }
int main() { //call primeSum() }
The main function should do the following:
1)Input: Read an integer from the user with proper prompt 2)Processing: Call primeSum() with an assignment statement and save the result in a variable. 3)Output: Print result with proper prompt.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
