1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natka813 [3]
3 years ago
14

In c the square root of a number N can be approximated by repeated calculation using the formula NG = 0.5(LG + N/LG) where NG st

ands for next guess and LG stands for last guess. Write a function that calculates the square root of a number using this method. The initial guess will be the starting value of LG. The program will com- pute a value for NG using the formula given. The difference between NG and LG is checked to see whether these two guesses are almost identical. If they are, NG is accepted as the square root; otherwise, the next guess (NG) becomes the last guess (LG) and the process is repeated (another value is computed for NG, the difference is checked, and so on). The loop should be repeated until the difference is less than 0. 005. Use an initial guess of 1. 0. Write a driver function and test your square root function for the numbers 4, 120. 5, 88, 36.01, 10,000, and 0. 25
PLEASE İN C PROGRAMMİNG
Engineering
1 answer:
DanielleElmas [232]3 years ago
8 0

Answer:

Following are the program to the given question:

#include <stdio.h>//header file

double square_root(double N, double initialGuess)//defining a method square_root that takes two variable in parameters

{

double NG, LG = initialGuess,diff;//defining double variable

while(1)//use loop to calculate square root value

{

NG = 0.5 * (LG + N / LG);//using given formula

diff = NG - LG;//calculating difference

if(diff < 0)//use if to check difference is less than 0

diff = -diff;//decreaing difference

if(diff < 0.005)//use if that check difference is less than 0.005

break;//using break keyword  

else//defining else block

{

LG = NG;//holding value

}

}

return NG;//return value

}

int main()//defining main method

{

double ans, n,initialguess = 1.0;//defining double variable

n = 4;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 120.5;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 36.01;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 0.25;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

printf("\nEnter a number: ");//print message

scanf("%lf", &n);//input value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

}

Output:

Please find the attachment file.

Explanation:

  • In this code, a method "square_root" is declared that takes two variable "N, initialGuess" in its parameters, inside the method a three double variable is declared.
  • It uses the given formula and uses the diff variable to hold its value and uses two if to check its value is less than 0 and 0.005 and return its calculated value.
  • In the main method, three double variables are declared that use the "n" to hold value and "ans" to call the method that holds its value and print its value.

You might be interested in
Which one is suitable for industries petrol engine or diesel engine and why?
klio [65]

Answer:

diesel engine

Explanation:

because diesel is stronger than petrol

3 0
3 years ago
Read 2 more answers
How can I draw this image in 2D form
Ket [755]

Answer:

no it is not 2D

Explanation:

it is 3D

ok so follow these steps

- make hole

-make square

-make triangle

ok now your figure is ready

5 0
2 years ago
You are given a body with no body forces and told that the stress state is given as: ⎡ ⎣ 3αx 5βx2 + αy γz3 5βx2 + αy βx2 0 γz3 0
Lady bird [3.3K]

Answer:

This doesn't represent an equilibrium state of stress

Explanation:

∝ = 1 , β = 1 ,  y = 1

x = 0 , y = 0 , z = 0 ( body forces given as 0 )

Attached is the detailed solution is and also the conditions for equilibrium

for a stress state to be equilibrium all three conditions has to meet the equilibrum condition as explained in the attached solution

5 0
3 years ago
A 10 wt % aqueous solution of sodium chloride is fed to an evaporative crystallizer which operates at 80o C. The product is a sl
VikaD [51]

Answer: The feed rate is

17,020kg/he and the rate is 13,520kg/h

Check the attachment for step by step explanation

3 0
3 years ago
What is the acceleration of a car that has a velocity of 20 m/s, and
ella [17]

Acceleration of Car = 10 ms⁻²

Explanation:

Step 1:

The basic formula of acceleration is a = (v-u)/t  ms⁻²

where, v- final velocity

            u- initial velocity

             t= time taken

Step 2:

Here v = 70 ms⁻¹

        u = 50  ms⁻¹

         t = 5 s

∴ a = ( 70 - 20)/5

a = 10 ms⁻²

7 0
3 years ago
Other questions:
  • What is the entropy of a closed system in which 25 distinguishable grains of sand are distributed among 1000 distinguishable equ
    5·2 answers
  • What is differences Between hard shoulder &amp; soft shoulder in civil Engineerin?
    9·1 answer
  • One of our wifi network standards is IEEE 802.11ac. It can run at 6.77 Gbit/s data rate. Calculate the symbol rate for 801.11ac
    5·1 answer
  • What determines the depth of the foundation excavation
    9·2 answers
  • Engineers design for everyone and consider all design challenges opportunities to problem-solve. The roller coaster in this phot
    5·1 answer
  • Which statement about lean manufacturing is true when you compare it to mass production?
    7·1 answer
  • Differentiate between isohyetal method and arithmetical average method of rainfall​
    10·1 answer
  • Eugene runs a company that manufactures bricks. The manufacturing process consumes a lot of energy and causes pollution, which t
    9·2 answers
  • Describe in your own words the three strengthening mechanisms
    7·1 answer
  • What is the role of engineers in nation building <br><br>​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!