Prepare a function that has two positive integer parameters


Question: Prepare a function that has two positive integer parameters (say high and low) that returns the number of powers of two between (but not equal to) those parameters. Your function can suppose that low is always less than high. For case, if low=3 and high=28, then your function should return 3 (because there are 3 powers of two between 3 and 28: 4, 8 and 16).

Write a main function that reads pairs of positive integers from the user, calls your function sending the two values read as arguments, and prints the value returned by your function.

Terminate execution when the user enters two numbers such that the first is not less than the second. You do not have to check for the input values being positive - just suppose the user never makes a mistake.

Ex) If the user inputs 3 and 28, the only powers of two between them are 4, 8, 16. So the output will be:

"There are 3 powers of two between 3 and 28."

There are 3 types of outputs: (suppose a and b are integers):

Part 1: - If there are no "powers of 2" in between the limits. ==> "There are no powers of two between a and b."

Part 2: - If there is only 1 "power of 2" in between the limits ==> "There is 1 power of two between a and b." (

Part 3:- If there are more than 1 "powers of 2" between the limits. ==> "There are 3 powers of two between a and b."

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Prepare a function that has two positive integer parameters
Reference No:- TGS0964659

Expected delivery within 24 Hours