Question: *PLEASE SHOW THAT THE CODE WORKS ACCORDING TO THE GIVEN DATA! Write a C++ program to read an integer from the user and compute the

*PLEASE SHOW THAT THE CODE WORKS ACCORDING TO THE GIVEN DATA!

Write a C++ program to read an integer from the user and compute the product of prime numbers smaller than that integer. Design and implement 2 functions: (1) a function to read the integer which ensures that the input is valid (e.g. not a float) and returns the integer that was read to the main function, and (2) a function that checks if a given number is prime. The main function will generate values less than the input and check if each value is a prime and compute the product. Pseudo-code below:

main(){ int max=0;

read max from user; //implement a function to read a valid max int product=1; for val=1 to max-1{

if val is prime //implement a function to check if val is prime which returns true or false product=product*val;

}

print sum; }

The above is just pseudo-code. It intentionally omits issues that need to be addressed in implementing a valid program that solves the given problem. In order to properly implement function #1 to read a valid integer from the user, you will need to do some research on cin.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!