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
What is an air mass?​
kotegsom [21]

Answer:

An air mass is a body of air with horizontally uniform temperature, humidity, and pressure.

Explanation:

Because it is

8 0
3 years ago
Read 2 more answers
Describe and compare the characteristics of (a) proportional control, (b) proportional plus integral control, (c) proportional p
stira [4]

Answer:

The answer is below

Explanation:

1. Proportional Control is a form of control engineering in which an output is directly proportional to the error signal.

Characteristics of proportional control are:

* It is utilized when the deviation between the input and output is small

* It is also utilized when the deviation is not sudden.

* It reduces steady-state error

* It speeds up the response of the overdamped system

2. Proportional plus Integral Control is a form of control engineering in which a collective proportion and integral control of the output is equivalent to the combined proportion and integral of the error signal.

Characteristics of proportional plus integral control are:

* it can revert the controlled variable to the original set point

* It decreases steady-state error

* It quickens up the reaction of the overdamped system

3. Proportional plus integral plus derivative control is mostly applicable in operating the process elements such as temperature, pressure, speed, etc. It is recommended for industrial use.

Characteristics of Proportional plus integral plus derivative control are:

* It enhances the temporary reaction of the system.

* It also lessens steady-state error

* It accelerates the response of the overdamped system

4 0
3 years ago
If 1 inch equals 10 feet, what would the measured distance be if the line scaled 1 1/2 inches?
Crank

Answer: B. 15 feet

Explanation:

4 0
3 years ago
Read 2 more answers
A charge of 11.748 nC is uniformly distributed along the x-axis from −2 m to 2 m . What is the electric potential (relative to z
svp [43]

Answer:

electric potential  =  22.36 volt

Explanation:

given data

charge Q =  11.748 nC

distance d = 5 - 2 = 3 m

length = 2 + 2 = 4 m

Coulomb constant = 8.98755 × 109 N·m²/C ²

solution

electric potential is express as

electric potential  = \frac{Q}{4\pi \epsilon  _o L} ln(1+\frac{L}{d})   ..............1

electric potential  = \frac{KQ}{L} ln(1+\frac{L}{d})  

put here value

electric potential  = \frac{8.98755\times 10^9\times 11.748\times 10{-9}}{4} ln(1+\frac{4}{3})  

electric potential  =  22.36 volt

6 0
3 years ago
PLEASE HELP ME!!!!!! IM LOW ON POINTS BUT I NEED SOME HELP, QUICK!!! POINTS FOR HELPFUL ANSWERS + BRAINLIEST!!!!!
meriva

Answer:

Kitchen sinks can be clogged for a few reasons, food hair, and other things. Overtime, buildup of these things lead to clogging.

A few methods to fix clogging are, baking soda mixture, plunging, and boiling water.

The first method, baking soda mixture, what you do is you pour a cup of baking soda and vinegar down the drain, and place a rubber stopper to cover the drain opening. Wait 10 or more minutes, and take out the stopper, and run hot tap water until it's unclogged.

The second method is plunging. Make sure the sink has enough water to submerge the plunger, and start plunging. While you are plunging, maintain a good seal to get the best results. This usually works, but sometimes it doesn't.

The last method is boiling water. Pour boiling water into the drain, then after a while, the clogged drain should unclog, if it doesn't repeat the process until necessary.

Explanation:

8 0
3 years ago
Other questions:
  • I want to cancel my subscription
    5·2 answers
  • What is the name for a part of a window that joins two windows into a single unit?
    12·1 answer
  • A pump is put into service at the coast where the barometric pressure is 760 mm Hg. The conditions of service are : Flow rate 0,
    11·1 answer
  • A refrigerator removes heat from a refrigerated space at 0°C at a rate of 2.2 kJ/s and rejects it to an environment at 20°C. wha
    15·1 answer
  • If a vehicle is built with a top speed of 140 mph, what should its tires minimum speed
    5·1 answer
  • When block C is in position xC = 0.8 m, its speed is 1.5 m/s to the right. Find the velocity of block A at this instant. Note th
    14·1 answer
  • The BARO sensor informs the PCM about changes in weather and ____________________.
    14·1 answer
  • A solid steel shaft ABCDE turns freely in bearings at points A and E. The shaft is driven by the gear at C, which applies a torq
    14·1 answer
  • The product of two factors is 4,500. If one of the factors is 90, which is the other factor?
    6·1 answer
  • Back Savers is a company that produces backpacks primarily for students. They are considering offering some combination of two d
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!