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
12. Never spray brakes with a high-pressure stream of water or air because it could blow asbestos fibers into the air.
emmainna [20.7K]

Answer:true

Explanation:

Because when u spray it blows fibers into the air

7 0
3 years ago
Calculate the density of the FCC nickel lattice with an interstitial hydrogen in the centered position of the unit cell. You may
Anastaziya [24]

Answer:

\rho=8907.94\ Kg/m^3

Explanation:

Given that

a=3.524 A

At.Wt. ,M= 58.7 g/mole,

 For FCC

 Z = 4

4r=\sqrt2\ a

The density given as

\rho=\dfrac{ZM}{N_Aa^3}

\rho=\dfrac{4\times 58.7\times 10^{-3} }{ 6.023\times 10^{23}\times (3.524\times 10^{-10})^3}

\rho=8907.94\ Kg/m^3

So the density is \rho=8907.94\ Kg/m^3

4 0
3 years ago
Chapter 15 – Fasteners: Determine the tensile load capacity of a 5/16 – 18 UNC thread and a 5/16 – 24 UNF thread made of the sam
Roman55 [17]

Answer:

The 5/16 – 24 UNF is stronger because it has more tensile load capacity.

Tensile load capacity for M8 -1.25 = 5670 lb

Tensile load capacity for M8 -1 = 6067 lb

Explanation:

For 5/16 - 18 UNC thread:

D = 0.3125

n = 18

Therefore the tensile load capacity is = 100000 X (0.7854 X (0.3125 - 0.9743/ 18) ^2

= 5243 lb.

Similarly for 5/16 - 24 UNF , only the n value changes to 24

we get the tensile load capacity = 5806.6 lb

Hence the 5/16 – 24 UNF is stronger because it has more tensile load capacity.

For metric Bolts:

We have to consider all values in SI units

Strength = 689 MPa

We get for M8 -1.25:

Tensile load capacity as = 689 X 36.6 = 25223 N = 5670 lb

For M8 -1:

Tensile load capacity as = 689 X 39.167 = 26986 N = 6067lb

7 0
3 years ago
Read 2 more answers
Vivian's Violins has sales of $326,000, contribution margin of $184,000 and fixed costs total $85,000. Vivian's Violins net oper
frosja888 [35]

Based on the calculations, Vivian's Violins net operating income is equal to: D. $99,000.

<h3>How to calculate net operating income?</h3>

Mathematically, the net operating income of an individual or business firm can be calculated by using this formula:

Net operating income = Contribution margin - Total fixed costs

<u>Given the following data:</u>

  • Sales = $326,000
  • Contribution margin = $184,000
  • Fixed costs total $85,000

Substituting the given parameters into the formula, we have;

Net operating income = $184,000 - $85,000

Net operating income = $99,000.

Read more on net operating income here: brainly.com/question/24165947

#SPJ1

5 0
2 years ago
For each function , sketch the Bode asymptotic magnitude and asymptotic phase plots.
horrorfan [7]

Answer:

attached below

Explanation:

a) G(s) = 1 / s( s+2)(s + 4 )

Bode asymptotic magnitude and asymptotic phase plots

attached below

b) G(s) = (s+5)/(s+2)(s+4)

phase angles = tan^-1 w/s , -tan^-1 w/s , tan^-1 w/4

attached below

c) G(s)= (s+3)(s+5)/s(s+2)(s+4)

solution attached below

5 0
3 years ago
Other questions:
  • A turbine produces shaft power from a gas that enters the turbine with a (static) temperature of 628 K, a velocity of 143 m/s an
    7·1 answer
  • Pascal's law tells us that, pressure is transmitted undiminished throughout an open container. a)- True b) False
    9·1 answer
  • The in situ moisture content of a soil is 18% and the moist (total) unit weight is 105 pcf. The soil is to be excavated and tran
    9·1 answer
  • he Weather Channel reports that it is a hot, muggy day with an air temperature of 90????F, a 10 mph breeze out of the southwest,
    6·1 answer
  • Based on the scenario, which type of engineering identifies Greg's role in Ethiopia?
    15·1 answer
  • What are the partial products of 2.3 x 2.6
    15·1 answer
  • Solved this question??????????????????
    13·1 answer
  • 14. The flow water in a 10-in Schedule 40 pipe is to be metered. The temperature of the water is
    8·1 answer
  • A coil consists of 200 turns of copper wire and have a cross-sectional area of 0.8 mmm square.The mean length per turn is 80 cm
    13·1 answer
  • Ferroconcrete is reinforced concrete that combines concrete and ________. A. Lead c. Copper b. Iron d. Aluminum.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!