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
Why doesn't any one give as many points as i do for random questions on brainly
erastova [34]

good question i like to give about 20. i think people just are cheapskates for most of their time on this planet. didnt need the 50 though but thanks.

4 0
2 years ago
Read 2 more answers
Contrast moral and immoral creativity and innovation<br>​
Archy [21]

Moral creativity and innovation are based on original discoveries,  whereas immoral innovation is based on unscrupulous actions.

<h3>What is innovation?</h3>

Innovation refers to the practices aimed at developing new products and services for the well-being of society.

Moral innovation is an expression generally used to describe technological advancements based on intellectual property rights.

In conclusion, moral creativity and innovation are based on original discoveries,  whereas immoral innovation is based on unscrupulous actions.

Learn more about innovation here:

brainly.com/question/19969274

#SPJ1

7 0
2 years ago
Which of the following statements about glycogen metabolism is FALSE?
Ratling [72]

Answer:

Glycogen is the primary energy source for muscle and liver cells.

Explanation:

Glycogen is a readily mobilized storage form of glucose. It is a very large, branched polymer of glucose residues that can be broken down to yield glucose molecules when energy is needed. Most of the glucose residues in glycogen are linked by α-1,4-glycosidic bonds. Branches at about every tenth residue are created by α-1,6-glycosidic bonds.

Glycogen is not as reduced as fatty acids are and consequently not as energy rich. Why do animals store any energy as glycogen? Why not convert all excess fuel into fatty acids? Glycogen is an important fuel reserve for several reasons. The controlled breakdown of glycogen and release of glucose increase the amount of glucose that is available between meals. Hence, glycogen serves as a buffer to maintain blood-glucose levels. Glycogen's role in maintaining blood-glucose levels is especially important because glucose is virtually the only fuel used by the brain, except during prolonged starvation. Moreover, the glucose from glycogen is readily mobilized and is therefore a good source of energy for sudden, strenuous activity. Unlike fatty acids, the released glucose can provide energy in the absence of oxygen and can thus supply energy for anaerobic activity.

3 0
3 years ago
It is known that the connecting rod AB exerts on the crank BCa 2.5-kN force directed down andto the left along the centerline of
monitta

Answer:

M_c = 61.6 Nm

Explanation:

Given:

F_a = 2.5 KN

Find:

Determine the moment of this force about C for the two casesshown.

Solution:

- Draw horizontal and vertical vectors at point A.

- Take moments about point C as follows:

                         M_c = F_a*( 42 / 150 ) *88

                         M_c = 2.5*( 42 / 150 ) *88

                         M_c = 61.6 Nm

- We see that the vertical component of force at point A passes through C.

Hence, its moment about C is zero.

6 0
3 years ago
X+3=2<br>x=??<br><br><br><br>No spamming​
PtichkaEL [24]

Answer:

x+3=2

x=2-3꧁

꧁꧁꧂꧂꧂꧂

x=-1

4 0
3 years ago
Other questions:
  • Briefly describe the purpose of specifying boundary conditions.
    7·1 answer
  • To prevent hydroplaning, _____. A. slow down B. speed up C. deflate your tires D. use cruise control
    15·1 answer
  • Which of the following scenarios describes someone who is a materials engineer?
    13·1 answer
  • Write an application named EnterUppercaseLetters that asks the user to type an uppercase letter from the keyboard. If the charac
    8·1 answer
  • According to the video, what are some of the effects of the increase in the use of automated tools for Loading Machine Operators
    10·2 answers
  • The normal stress at gage H calculated in Part 1 includes four components: an axial component due to load P, σaxial, P, a bendin
    9·1 answer
  • Often an attacker crafts e-mail attacks containing malware designed to take advantage of the curiosity or even greed of the reci
    14·1 answer
  • What is the chord length of an airplane called?
    14·1 answer
  • The build up of electrons will cause electrical called ?
    14·1 answer
  • How much energy in joule is added to a 12 g of sample of aluminum (c=0.897 J/g ◦C) to raise the temperature from 20 ◦C to 45 ◦C?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!