Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
