C++ Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows:

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

In C++

Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows:

A = 12345

B = A + 5000

Note: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29.

Rules:

  1. You should first create a boolean function called isPrime and use that function in your program. This function should take in any int and return true if the number is prime, otherwise, return a false. In the main body of your program, you should create a loop from A to B (inclusive) and use isPrime function to determine if the loop number should be counted or not.

  2. Your program SHOULD NOT PRINT the individual prime numbers. You can print them for your own testing purpose, but in the final submission, comment out such print statements.

  3. Your program SHOULD ONLY PRINT the answer -- which is a number.

  4. Do not print extra characters in your answer (E.g. "answer=123" instead of 123)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr