Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The square root of a number x can be approximated by the repeated application of the following formula: y(i) = (y(i-1)+ x/y(i-1) where y(i) is

The square root of a number x can be approximated by the repeated application of the following formula:

y(i) = (y(i-1)+ x/y(i-1)

where y(i) is the new estimate of the square root of x at iteration i, and y(i-1) is the estimate on the previous round.

Prompt the user to enter a positive number. Check whether the number is positive. If not, re-prompt the user to enter a positive number. Calculate the square root of the user's input using a C function that yields an accuracy of 5 decimal digits. That is, the new and the old estimate differ by less than 10^-5.

Use the following function prototype

 double root(double x);

image text in transcribed

The square root of a number x can be approximated by the repeated application of the following formula: y() = (y(i-1)+ x/y(i-1) where y(i) is the new estimate of the square root of x at iteration i, and y(i-1) is the estimate on the previous round. Prompt the user to enter a positive number. Check whether the number is positive. If not, re-prompt the user to enter a positive number. Calculate the square root of the user's input using a C function that yields an accuracy of 5 decimal digits. That is, the new and the old estimate differ by less than 10^-5. Use the following function prototype double root (double x); Sample Output Enter a positive number: -5 The number has to be positive. Enter a positive number: 7 The square root of 7 is 2.64575 301608.1549906 LAB ACTIVITY 16.25.1: Lab 4: P3(W): Square Root Approximation 0/4 main.c Load default template... 1 #include 2 #include 3 4 double root(double x); 5 6 int main() { /* Type your code here. */ 9 10 return 0; 11 } 12 13 double root(double x){ 14 15 // write your function here 16 17 }

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago