Write a main function that reads pairs of positive integers

Assignment Help C/C++ Programming
Reference no: EM13711399

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."

Reference no: EM13711399

Questions Cloud

Prepare a program to triple each number in the list : Write a program that will read in a list of numbers, triple each number in the list and print the result - Write a program that will read in 2 numbers per line, and print the sum.
How can you visualize a 4-dimensional array : How can you visualize a 4-dimensional array - How can you give meaning to each dimension this array has?
What are the limits for each one of these indexes : What are the limits for each one of these indexes and is it possible to model a 2-dimensional array with a single-dimensional array?
How many independent memory channels should be provided : how many independent memory channels should be provided so the system is not limited by memory bandwidth if the bandwidth required is sometimes twice the average?
Write a main function that reads pairs of positive integers : 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.
Explain triggers & operational data : Briefly describes three types of triggers. What is a stored procedure? How do they differ. Why is operational data sometimes unusable for Business Intelligence use.
Implementations of the adt bag : Compare the array-based and link-based implementations of the ADT bag operation remove(anEntry). Suppose the different locations of anEntry within the array or chain.
Define a method for linkedbag : Add a constructor to the class LinkedBag that creates a bag from a given array of entries - define a method for LinkedBag that removes a random entry from the bag.
Prepare a windows application : A national Digital service provider would like you to prepare a Windows application that will display the global growth of smart phones.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a function that takes two point arguments

Write a function that takes two POINT arguments and returns the midpoint between them and define a function distance() that takes two POINT arguments and returns the distance between them.

  Write and test a c function named flow that returns both

fluid following in a pipe flows in a smooth pattern knows as laminar flow or a turbulent pattern know as turbulent

  Project

Unit 3 Individual Project SSCI210 – 1304B – 01 A typical individual who commits who commits hate crimes whether it is against or aimed at the Gay/lesbian community , the persons of color or the Jewish community, ( I mention these three because they a..

  Write a program that uses a nested loop

Write a program that uses a nested loop togenerate the output shown below. Be sure that the value on the line changes with each digit displayed. For example, line 5 has the values "1", "2", "3", "4", and "5".

  Questionnbspnbspi have a product called neverwet that

questionnbspnbspi have a product called neverwet that creates a hydrophobic surface on stuff. theres a base and top

  Display the complete fibonacci sequence

Display the complete Fibonacci sequence until you reach a value less or equal than 1,000,000 (one million) - display the division of the number by the previous one for the complete sequence.

  Reads numbers from input and prints them in reverse order

Write a C program that reads ten numbers from input and prints them in reverse order. We assume that the data consists of integers. The program should conform to the following format:

  Design your application according to the considerations

Design your application according to the considerations described above.  For example, you must use functions that have the specified signatures, and arrays that have the specified declarations. They are

  State a c program that opens the file

Write a C program that opens the file and firstly stores all the values in an appropriately declared two-dimensional array of integers. It then should analyse this array to find (from the 40 input values) the total number of coursework marks in the..

  Write a program that stimulates a bouncing ball

Write a program that stimulates a bouncing ball by computing its height in feet at each second as time passes on a simulated clock. At time zero, the ball begins at height zero.

  Define a class named payment that contains an instance

Define a class named Payment that contains an instance variable of type double that stores the amount of the payment and appropriate accessor and mutator methods.

  Prepare a program in c++ using the class as defined

Prepare a program in C++ using the class as defined below - Then write the main program in another file that will read in some numbers and test out whether your functions all work.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd