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]
2 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]2 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
What does an aeronautical engineer design
Colt1911 [192]

Answer:

they work with aircraft, designing aircrafts.

Explanation:

3 0
3 years ago
¿Qué áreas del conocimiento me pueden<br> aportar a la ejecución del proyecto?
allsm [11]

Answer:

la escuela,en casa y listo...............

8 0
2 years ago
Energy.
alexandr402 [8]

Answer:

modern vehicles are made to crunch up a little bit so they that absorbe some of the impact instead of you

Explanation:

8 0
2 years ago
Using a forked rod, a 0.5-kg smooth peg P is forced to move along the vertical slotted path r = (0.5 θ) m, whereθ is in radians.
-BARSIC- [3]

Answer:

N_c = 3.03 N

F = 1.81 N

Explanation:

Given:

- The attachment missing from the question is given:

- The given expressions for the radial and θ direction of motion:

                                       r = 0.5*θ

                                       θ = 0.5*t^2              ...... (correction for the question)

- Mass of peg m = 0.5 kg

Find:

a) Determine the magnitude of the force of the rod on the peg at the instant t = 2 s.

b) Determine the magnitude of the normal force of the slot on the peg.

Solution:

- Determine the expressions for radial kinematics:

                                        dr/dt = 0.5*dθ/dt

                                        d^2r/dt^2 = 0.5*d^2θ/dt^2

- Similarly the expressions for θ direction kinematics:

                                        dθ/dt = t

                                        d^2θ/dt^2 = 1

- Evaluate each at time t = 2 s.

                                        θ = 0.5*t^2 = 0.5*2^2 = 2 rad -----> 114.59°

                                        r = 1 m , dr / dt = 1 m/s , d^2 r / dt^2 = 0.5 m/s^2

- Evaluate the angle ψ between radial and horizontal direction:

                                        tan Ψ = r / (dr/dθ) = 1 / 0.5

                                        Ψ = 63.43°

- Develop a free body diagram (attached) and the compute the radial and θ acceleration:

                                        a_r = d^2r / dt^2 - r * dθ/dt

                                        a_r = 0.5 - 1*(2)^2 = -3.5 m/s^2

                                        a_θ =  r * (d^2θ/dt^2) + 2 * (dr/dt) * (dθ/dt)

                                        a_θ = 1(1) + 2*(1)*(2) = 5 m/s^2

- Using Newton's Second Law of motion to construct equations in both radial and θ directions as follows:

Radial direction:              N_c * cos(26.57) - W*cos(24.59) = m*a_r

θ direction:                      F  - N_c * sin(26.57) + W*sin(24.59) = m*a_θ

Where, F is the force on the peg by rod and N_c is the normal force on peg by the slot. W is the weight of the peg. Using radial equation:

                                       N_c * cos(26.57) - 4.905*cos(24.59) = 0.5*-3.5

                                       N_c = 3.03 N

                                       F  - 3.03 * sin(26.57) + 4.905*sin(24.59) = 0.5*5

                                       F = 1.81 N

4 0
3 years ago
Which goal incorporates most of the criteria required for a SMART goal?
STatiana [176]

Answer:

e

Explanation:

8 0
3 years ago
Other questions:
  • Describe three advantages and three disadvantages of JIT?
    12·1 answer
  • Cng containers need to be inspected
    7·1 answer
  • Can i join three 12 volts batteriesto give me 24 volts output​
    9·1 answer
  • Which is the correct order for handwashing
    11·2 answers
  • Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B tr
    9·1 answer
  • Se requiere un permiso aprobación o restricción contaminante para todos los métodos comerciales de descarga de aguas residuales
    13·1 answer
  • Saturated steam coming off the turbine of a steam power plant at 40°C condenses on the outside of a 3-cm-outer-diameter, 35-m-lo
    7·1 answer
  • Might give brainliest
    8·1 answer
  • How much memory can a 32 -bit processor support ?
    13·1 answer
  • A restaurant and dairy are participating in a community digester pilot program within the UMD Industrial Park. The following was
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!