Question: Open the power_of_primes.cpp file and update the file to perform the following: (a) Prompt the user to enter a non-negative integer x and read the

Open the power_of_primes.cpp file and update the file to perform the following: (a) Prompt the user to enter a non-negative integer x and read the value (you are not required to check if the input is non-negative; just assume it is). (b) Write the logic which checks if x can be written as a power of two primes; that is, check if there exist two prime integers a and b such that x = ab. If you can write x as a power of primes, print \"Yes\" and print these primes that you found; otherwise, print \"No, x cannot be written as a power of primes\". Hints: An integer n is prime if n > 2 and n does not have any divisor other than 1 and itself. The logic for checking if an integer is prime or not is already given to you in the function is Prime which is provided above main (do not worry, you are not expected to understand the syntax because you did not learn about functions yet). Thus, you are not required to write the logic to check if a and b are prime; instead, you can directly use the given function. For example, you can write isPrime(a) to check if a is prime; this will give you a Boolean value: true if a is prime and false otherwise. (c) Ask the user to enter another integer N (assume it is positive), and print the first N positive integers which satisfy the condition in part b: for each one of these, print the corresponding primes (see the sample inputs/outputs below),

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 Programming Questions!