Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need the program in c so that I can see how it's worked out, again please in c, not c# or c++. thanks bunches. Objective

image text in transcribed

need the program in c so that I can see how it's worked out, again please in c, not c# or c++. thanks bunches.

Objective Demonstrate use of a while) loop for an undetermined number of iterations. Background An ancient method for finding square roots turned out to be a special case of what is today called Newton's method for root finding. It's so efficient and simple that it is still frequently used in computers today. An algorithm is a step-by-step process for solving a problem. You have already developed algorithms in previous homework assignments, but they were simple enough that you essentially did them in your head as opposed to writing them down. The algorithm for finding square roots using Newton's method can be written as follows. Note that this format is commonly used in technical and scientific papers. Algorithm Square Root using Newton's method 1. function sqrt(x) Choose a small value, Choose initial value for y (e.g. Yo = 1.0) While y - xl> Yn+1 = + yn) Return y There is a similarity between the algorithm and actual code, but the algorithm is written in a way that it could be implemented in any language, so it is not specific to C. Assignment 1. Write a function to find square roots of positive numbers using the algorithm above. It should a parameter and return a double as the answer. Use a value of 0.0001 for epsilon (). a. Be sure to add #include at the top of your program. b. The standard function fabs(x) will find the absolute value of x. C. Use 1.0 as the initial value of y. 2. In main(), use a for() loop to calculate and print the square roots of the numbers 2 thru 8 to four decimal places. Your output should look something like this: The square root of 2 is 1.4142 The square root of 3 is 1.7321 Etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago