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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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