Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show C code for below. Task: Write a program than calculates the square root of a positive number entered by the user Instructions: Write

Please show C code for below.

  • Task:
    • Write a program than calculates the square root of a positive number entered by the user
  • Instructions:
    • Write a main module (file Main.c) that prompts the user for a value and prints the calculated square root
    • Write a square root module (files sqrt.c and sqrt.h) which implements a function with the signature double SquareRoot(double)
    • Write a corresponding Makefile to compile the program
  • Square Root Approximation Algorithm:
    • Input: positive real number N
    • Output: square root of N
    • Approximate the square root by use of a range {L, R}, where L sqrt(N) R
    • Start with the range {0, max(1,N)}
    • Calculate the middle of the range M = L + (R-L)/2
    • If the square root of N lies in the lower half of the range, use {L, M} as new range; otherwise use {M, R}
    • Repeat the bisection until the range is smaller than 1*10-5
    • Output M
  • Hint:
    • L sqrt(N) R is equivalent to L*L N R*R

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

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions

Question

5. Describe how contexts affect listening

Answered: 1 week ago