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
A bus travels the 100 miles between A and B at 50 mi/h and then another 100 miles between B and C at 70 mi/h.
stira [4]

Answer:

c. less than 60 mi/h

Explanation:

To calculate the average speed of the bus, we need to calculate the total distance traveled by the bus, as well as the total time of travel of the bus.

Total Distance Traveled = S = 100 mi + 100 mi

S = 200 mi

Now, for total time, we calculate the times for both speeds from A to b and then B to C, separately and add them.

Total Time = t = Time from A to B + Time from B to C

t = (100 mi)/(50 mi/h) + (100 mi)(70 mi/h)

t = 2 h + 1.43 h

t = 3.43 h

Now, the average speed of bus will be given as:

Average Speed = V = S/t

V = 200 mi/3.43 h

<u>V = 58.33 mi/h</u>

It is clear from this answer that the correct option is:

<u>c. less than 60 mi/h</u>

7 0
3 years ago
A(n)___ branch circuit supplies two or more receptacles or outlets for lighting and appliances
Juli2301 [7.4K]

Answer: General purpose branch circuit

Explanation:

General purpose branch circuit are the type of circuits that are used mainly to supply light to two or more receptacle outlets for small appliances. This circuits are about 120v can be used either in residential, commercial and industrial buildings.

6 0
3 years ago
Question 1 A design team completes their high-fidelity prototype of a responsive website. Before they hand off designs to the en
MissTica

A question the design team should answer before handing off the designs is: are the designs a true representation of the intended end user experience?

<h3>What is a website?</h3>

A website can be defined as a collective name that is used to describe series of webpages that are interconnected or linked together with the same domain name.

In Computer technology, the main goal of a high-fidelity prototype is to understand how end users would interact with a website and areas to improve the design.

In conclusion, the design team should answer whether or not the designs are a true representation of the intended end user experience before handing off the designs.

Read more on website here: brainly.com/question/26324021

5 0
2 years ago
Ethylene glycol, the ingredient in antifreeze, does not cause health problems because it is a clear liquid.
netineya [11]
B. false

Explanation: because it is
5 0
2 years ago
A labor-intensive process to manufacture a product has a fixed cost of $338,000 and a variable cost of $143 per unit. An automat
ozzi

Answer:

no of unit is 17941

Explanation:

given data

fixed cost = $338,000

variable cost = $143 per unit

fixed cost = $1,244,000  

variable cost = $92.50 per unit

solution

we consider here no of unit is = n

so here total cost of labor will be sum of fix and variable cost i.e

total cost of labor = $33800 + $143 n  ..........1

and

total cost of capital intensive  = $1,244,000 + $92.5 n   ..........2

so here in both we prefer cost of capital if cost of capital intensive less than cost of labor

$1,244,000 + $92.5 n  <  $33800 + $143 n

solve we get

n > \frac{906000}{50.5}

n > 17941

and

cost of producing less than selling cost so here

$1,244,000 + $92.5 n < 197 n

solve it we get

n > \frac{1244000}{104.5}  

n > 11904

so in both we get greatest no is 17941

so no of unit is 17941

3 0
3 years ago
Other questions:
  • Consider a simple ideal Rankine cycle and an ideal regenerative Rankine cycle with one open feedwater heater. The two cycles are
    15·1 answer
  • Superheated steam is stored in a large tank at 6 MPa and 800°C, The steam is exhausted isentropically through a converging-diver
    5·1 answer
  • What does WCS stand for? A. Western CAD System B. Worldwide Coordinate Sectors C. World Coordinate System D. Wrong CAD Settings
    10·1 answer
  • Determine the magnitude of the resultant force and the moment about the origin. Note: the symbol near the 140 N-m moment are not
    15·1 answer
  • When trying to solve a frame problem it will typically be necessary to draw many free body diagrams. a)-True b)-False
    6·1 answer
  • What is the most common type of pump?
    11·1 answer
  • potential difference is the work done in moving a unit positive charge from one point to another in an electric field. State Tru
    12·1 answer
  • Oliver is designing a new children’s slide to increase the speed at which a child can descend. His first design involved steel b
    15·1 answer
  • How do i play Fortnite on controller?
    6·2 answers
  • Three spheres are subjected to a hydraulic stress. The pressure on spheres 1 and 2 is the same, and they are made of the same ma
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!