Square root of a number n

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

USING C++ the square root of a number N can be approximated by repeated calculation using the formula NG=.5(LG+N/LG) where NG stands for next guess and LG stands for last guess. Write a function that implements this computation. Thefirst parameter will be a positive real number, the second will be an intial guess of the square root of that number, and the third will be the computed result. the intial guess will be the starting value of LG. the function will compute a value for NG using the formula above. To control the computation, we can use a while loop. Each time through the loop , the difference between NG and LG is checked to see whether these two guesses are almost identical. If so, the function returns NG as the square root; otherwise, the next guess(NG) becomes the last guess (LG) and the process is repeated (that is, another value is computer for NG, the difference is checked, and so forth) for this problem the loop should be repeated until the magnitude of the difference between LG and NG is less than 0.005.

Reference no: EM13167073

Questions Cloud

Write a method called rectsum : Write a method called rectSum that will get the sum of a rectangle of elements within a 2D array of ints
Driveway is a "last-in, first-out" stack. of course : Driveway is a "last-in, first-out" stack. Of course, when a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave. Write a program in Java that m..
Create an erd and relatioal schema : Create an ERD and relatioal schema in third normal form based upon the following business rules. (Hint: ensure that all attributes are FULLY DETERMINED by the primary key.) Don't forget to place your normalization arrows on your relational schema.
Describe the equivalence classes : Prove that these relations on the set of all functions from Z to Z are equivalence relations. Describe the equivalence classes.
Square root of a number n : USING C++ the square root of a number N can be approximated by repeated calculation using the formula NG=.5(LG+N/LG) where NG stands for next guess and LG stands for last guess
Initialize cell arrays with 5 names, : Initilanize cell arrays with 5 names, 3 verbs, and 4 nouns of you choice. Print 10 sentences using one random element from each cell array. (e.g. 'Xavier eats pie').
Assume there are n nodes : Assume there are N nodes connected to a wireless access point (AP) operating on IEEE 802.11b, and every node has at least one packet to send at a given time.
Using songs.dat in our folder : Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,
Using notepad that implements a basic text analyzer : Write a Java application using Notepad that implements a basic Text Analyzer.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Recognition of the problem by the hsbc

What problem did the HSBC face in this case? What people, technology, and the organization factors were responsible for problem? Did HSBC management correctly recognize the problem?

  Takes a string containing a full name

Write a program that takes a string containing a full name and outputs each part of the name separately with its length. The name should be in the form of first, middle, and last name, separated from each other by a single space. For example, if the ..

  Add a sentinel command to stop the loop

add a sentinel command to stop the loop. When the program is compiled, It'll ask the user to type in a palindrome. I want the user to type EXIT to end the loop.

  Multiply a set of complex numbers

Write a C program to multiply a set of complex numbers stored in an array (that has been dynamically allocated). Specifically, first prompt the user to enter how many complex numbers need to be multiplied, dynamically create an array to store the ..

  Two types of sporting teams

Select two types of sporting teams and de?ne subclasses for them. These classes shouldinherit from a base team class such as that created in Exercise 1. Include uniquecharacteristics about the sport.

  Insert the missing code in the c program

You are to insert the missing code in the C program given for combinational equivalence checking. This program will interface with the CUDD package and will parse netlist files in ISCAS85 circuit format. Next, BDDs will be created for each circuit an..

  Create a file, shared.txt

When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

  C++ pointer function synopsis

C++ pointer Function Synopsis: char *amonthLess(char *dateString) Description: Variable dataString is a valid date in a form of mm/dd/yyyy Given the above information, write a main() program that asks a user to enter a date in a form of mm/dd/yyyy..

  We have to deal with student pilots

We have to deal with student pilots and airplanes. Students have a unique student id, a name, and a year that students are in. Airplanes have a unique airplane id, model, a cruising range

  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.

  Assign passed value to function to return value

Assign passed value to this member and another function to return value. Your main should read the integer from an input data file, and write the output to the output data file.

  Prepare the weighted scoring model for three exams

Prepare the weighted scoring model. Final grades are based on three exams worth 15%, 20%, and 25%, respectively; homework is worth 20%.

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