← Back to Modular Programming
Question 180
Helper Function for Primes
Helper Function for Primes
Build a modular program using a helper function. Write two functions: 1) boolisPrime(int n)that returns true if n is prime (n must be at least 2 and have no divisors other than 1 and itself). 2) intcountPrimes(int limit)that returns how many numbers from 2 up to and including limit are prime. It must USE isPrime. Do NOT write a main function.
Expected Output:
4 8
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Modular Programming
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.