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
1. A 260 ft (79.25 m) length of size 4 AWG uncoated copper wire operating at a tem-
Murljashka [212]

A 260 ft (79.25m) length of size 4 AWG uncoated copper wire operating at a temperature of 75°c has a resistance of 0.0792 ohm.

Explanation:

From the given data the area of size 4 AWG of the code is 21.2 mm², then K is the Resistivity of the material at 75°c is taken as ( 0.0214 ohm mm²/m ).

To find the resistance of 260 ft (79.25 m) of size 4 AWG,

R= K * L/ A

K = 0.0214 ohm mm²/m

L = 79.25 m

A = 21.2 mm²

R = 0.0214 * \frac{79.25}{21.2}

  = 0.0214 * 3.738

  = 0.0792 ohm.

Thus the resistance of uncoated copper wire is 0.0792 ohm

5 0
3 years ago
Which measuring tool will be used to determine the diameter of a crankshaft journal?
guapka [62]

Answer:

The dial bore gauge measures the inside of round holes, such as the bearing journals. This one tool can measure 2″ up to 6″ diameter holes. Both tools are needed in order to check the interior and exterior dimensions of the crankshaft, rods and engine block journals, as well as the thickness of the bearings themselves.

Hope it's helpful to you

pls mark me as brain list

4 0
3 years ago
A fatigue test was conducted in which the mean stress was 90 MPa (13050 psi), and the stress amplitude was 190 MPa (27560 psi).
Gwar [14]

Answer:

a) 280MPa

b) -100MPa

c) -0.35

d) 380 MPa

Explanation:

GIVEN DATA:

mean stress \sigma_m = 90MPa

stress amplitude \sigma_a = 190MPa

a) \sigma_m =\frac{\sigma_max+\sigma_min}{2}

    90 =\frac{\sigma_{max}+\sigma_{min}}{2} --------------1

\sigma_a =\frac{\sigma_{max}-\sigma_{min}}{2}

   190 = \frac{\sigma_{max}-\sigma_{min}}{2} -----------2

solving 1 and 2 equation we get

\sigma_{max} = 280MPa

b) \sigma_{min} = - 100MPa

c)

stress ratio=\frac{\sigma_{min}}{\sigma_{max}}

=\frac{-100}{280} = -0.35

d)magnitude of stress range

                      =(\sigma_{max} -\sigma_{min})

                       = 280 -(-100) = 380 MPa

3 0
3 years ago
Which of the following is the last step in creating a budget?
Greeley [361]

Answer:

<em>D. Determine saving or debt</em>

Explanation:

7 0
3 years ago
What can be the main disadvantage of pulse amplitude modulation?​
Feliz [49]

Answer:

transmission bandwidth required is very large.

Explanation:

4 0
2 years ago
Other questions:
  • A device that helps increase field worker productivity by providing reliable location and time
    13·1 answer
  • What is compression ratio of an Otto cycle? How does it affect the thermal efficiency of the cycle?
    14·1 answer
  • Firefighters are holding a nozzle at the end of a hose while trying to extinguish a fire. The nozzle exit diameter is 8 cm, and
    9·1 answer
  • PLS HELP ME
    14·1 answer
  • Please help me:<br> Use the Node analysis to find the power of all resistors
    9·1 answer
  • What did August Comte contribute to sociology including positivism
    11·1 answer
  • What learning is required to become a mechanical engineer?
    14·1 answer
  • If the load parameters are: Vln=600kV, Il=100A (resistive), calculate the source voltage and current when the line is 50Miles (s
    14·1 answer
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
  • 1. What did observations between 1912 and 1917 show?_____
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!