Ng stands for next guess

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

The square root of a number N can be approximated by repeated calculation using the formula NG = 0.5( LG + N/ LG)

where NG stands for next guess and LG stands for last guess. Write a function that calculates the square root of a number using this method. The initial guess will be the starting value of LG .

The program will compute a value for NG using the formula given. The difference between NG and LG is checked to see whether these two guesses are almost identical. If they are, NG is accepted as the square root; otherwise, the next guess (NG) becomes the last guess (LG) and the process is repeated (another value is computed for NG, the difference is checked, and so on). The loop should be repeated until the difference is less than 0.005. Use an initial guess of 1.0. Write a driver function and test your square root function for the numbers 4, 120.5, 88, 36.01, 10,000, and 0.25.

Reference no: EM13164926

Questions Cloud

Write a simple java program that will read an array of info : write a simple java program that will read an array of information containing the information (Name, offence [between arson, assault or theft] and year of offence
Class automobile has a composite object : Assume that a definition of class Automobile has a composite object called my Engine. Also assuembers of class Engine me the all the data members of class Engine that contain information
Calculate number of grams of aluminum required to prepare : Calculate the number of grams of aluminum required to prepare 500.0g of chromium metal.
Two-dimensional arr named number of three rows : Given a two-dimensional arr named number of three rows and four columns of type ont, write the nigle code statement that both declare and initialize the arry such that the first row is initialize to 0,1,2,3, the second row is initialized to 4,5,6,..
Ng stands for next guess : Where NG stands for next guess and LG stands for last guess. Write a function that calculates the square root of a number using this method. The initial guess will be the starting value of LG .
Would king and queen be liable to efl : Would your answer change if EFL had written to King and Queen advising you that they intended to make a loan to Impulse and were relyingon the 2012 audited financial report to assist them in making their decision?
Gender-specific terms : I think it is problematic to use gender-specific words like the examples of "policeman" and "waitress". The reason is these words are reflecting stereotypical descriptions of roles that are appear to be male or female exclusively. This is considered ..
What is the final temperature of the block : Assume that the heat required for the vaporization of the alcohol comes only from the aluminum block and that the alcohol vaporizes at 25. Suppose that 1.15 of rubbing alcohol evaporates from a 65.0 aluminum block.
The counter each time it''s clicked : Write a simple script that contains a button and a counter in a div. The button's event handler should increment the counter each time it's clicked.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program that reads in the average monthly

Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfa..

  Implement a semantic analysis

The program will implement Semantic Analysis. The assignment provides two options to define variable scope, either using the Global Option or the Local Option.

  Write a function num_digits(n)

C programing, not C++ write a function num_digits(n) that returns the number of digits in a nonnegative integer n.

  Write a corresponding if else statement

The mathematical operation max(x,y,w,z) can be represented by using the conditional expression operator, as in:  max = (x > y && x > z && x > w) ? x : ((y > z && y > w) ? y : ((z > w) ? z : w))  Write a corresponding if else statement that is equival..

  Reads in a list of integers

Write a program in C++ that reads in a list of integers into and array with base type int. Provide the facility to either read this array from the keyboard or from a file, at the user's option. If the user chooses file input, the program should reque..

  Individual genes are substrings of a genome

Individual genes are substrings of a genome delineated by 3-element start and stop codons. Genes begin with the start codon ATG and end with one of the following 3 stop codons: TAG, TAA or TGA. Note that start codons can appear anywhere in the string..

  50 element array of integers with random numbers

write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.

  Display the array, the average and the number of days above

Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.

  Describe the probability of the moves

Write a program in C++ to describe the Probability of the moves

  After the user presses any key

After the user presses any key, the board will be scrambled by making a large number of random moves (for a 3x3 puzzle, 100,000 attempted random moves in random directions will result in a sufficiently scrambled board)

  Write program to read from file to find number of integers

Write down the program which reads from file numbers.txt 30 integers in range 0 - 200. Program ‎then determines number of integers in each of given ranges.

  Pointer variables to demonstrate shallow and deep copy

Using C++, write a program that uses pointer variables to demonstrate shallow and deep copy. The program should give the user the choice to do the following:

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