Write a program that inputs an integer for n

Assignment Help Basic Computer Science
Reference no: EM13308003

The Babylonian algorithm to compute the square root of a number n is as follows:
1. Make a guess at the answer (you can pick n/2 as your initial guess).
2. Compute r = n / guess
3. Set guess = (guess +r) / 2
4. Go back to step 2 for as many iterations as necessary. The more that steps 2 and 3 are repeated, the closer guess will become to the square root of n.

Write a program that inputs an integer for n, iterates through the Babylonian algorithm twenty times, and outputs the answer as a double to two decimal places. Your answer will be most accurate for small values of n.

Reference no: EM13308003

Questions Cloud

How high does the pendulum swing : A ballistic pendelum of mass 1kg is struck by a 0.003kg bullet moving at 600 m/s. How high does the pendulum swing
initialize the temperature to 100 degrees celsius : Initialize the temperature to 100 degrees Celsius. In a loop, decrement the Celsius value and compute the corresponding temperature in Fahrenheit until the two values are the same.
Determine the principal stresses and the principal angle : using the stress transformation quations only,given a stress state where sigma x=6500 psi,sigma y= 17,300 psi and tau xy=2900 psi, determine the principal stresses,the principal angle and the maximum shear stress.
Ongoing data exploration : Ongoing Data Exploration
Write a program that inputs an integer for n : Write a program that inputs an integer for n, iterates through the Babylonian algorithm twenty times, and outputs the answer as a double to two decimal places. Your answer will be most accurate for small values of n.
How far does the mass move up along the plane : A mass of 10kg is sliding up a frictionless plane inclined at 10 degree. How far does the mass move up along the plane
What length does the observer measure : A spaceship is measured to be 158 m long while at rest relative to the observer. what length does the observer measure
Find the difference in volume between the cubes : You construct two wire-frame cubes, one using (infinitely thin) copper wire, the other using (infinitely thin) aluminium wire. Find the difference in volume between the cubes
Determine stresses acting on an element oriented at angle : Using the stress transformation equations only,given a stress state where sigma x=105 MPa,sigma y=75 MPa and tau xy=25 MPa, determine the stresses acting on an element oriented at an angle 40 degrees from the x axis.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Create implementation plan to analyze options

Boardman plans to hire Smith Systems Consulting to help them analyze their options and to create the implementation plan.

  Mips uses word alignment

MIPS uses word alignment, so all words are stored in memory on word boundaries; this means that address bits A[1:0] are always 00. How many and which address bits would be allocated for the set index?

  Exploit wildcard feature in order to cheat system

How could Dave, dishonest teller, exploit the wildcard feature  to cheat the system? Dave would want to concentrate on vouchers that are nearly one year old since such vouchers are likely to have been lost.

  Computer the value of the given number

Prompt the user for a number and an exponent. Computer the value of the given number (the base) raised to the power of the exponent.

  Probability of heavy- normal and light snowfalls

Brenda evaluates the probability of heavy, normal, and light snowfalls as 0.25, 0.6, and 0.15, respectively. So what must be size of the order you would suggest to Brenda? Justify why.

  Find the type of grammar

S - > a ? b | b ? c | aB S-> ? S|b

  Override the insert method in bst

You should override the insert method in BST. Your overriding method should first call the method it is overriding. When 50 insertions have been performed since the last rebalancing.

  How does disaster recovery planning ensure business continui

How does disaster recovery planning ensure business continuity?

  Advantages and disadvantages of grassroots computing

Discuss how grassroots computing changes the way software is designed, developed, tested, and maintained in a typical organization. What are the advantages and disadvantages of grassroots computing?

  How would you instantiate a resistor object

How would you instantiate a Resistor object with the parameterized constructor and with the default constructor

  How entry level manager adjust able to grow into upper level

How do you think an entry level manager has to adjust to be able to grow into an upper level manager

  How many disk i-o operations needed to read contents

How many disk I/O operations might be need to read contents of small local file at /a/b/c? suppose that none of disk blocks is presently being cached.

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