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 refrigerator operating on the Carnot cycle is used to make ice. Water freezing at 32oF is the cold reservoir. Heat is rejected
Mnenie [13.5K]

Answer:

Explanation:

From the given information:

Water freezing temp. T_L = 32 ^0 \ F

Heat rejected temp T_H = 72 ^0 \ F

Recall that:

The coefficient of performance is:

COP_{ref} = \dfrac{T_L}{T_H - T_L} \\ \\  = \dfrac{32+460}{(72 +460) -(32+460)} \\ \\ =\dfrac{492}{532 -492} \\ \\ = \dfrac{492}{40} \\ \\ COP_{ref} = 12.3

Again:

The efficiency given by COP can be represented by:

COP = \dfrac{Q_L}{W} \\ \\ W = \dfrac{Q_L}{COP} \\ \\ W = \dfrac{2000 \ lbm \times 144 \ Btu/lbm}{12.3} \\ \\ W = 23414.63 \ Btu

Finally; the power input in an hour can be determined by using the formula:

Power= \dfrac{W}{t} \\ \\  Power = \dfrac{23414.63 \ Btu}{ 1 \ hr} \\ \\  Power = \dfrac{23414.634 \times 1055.056 \ J}{1 \times 3600} \\ \\  Power  = 6.86 \ kW

In hp; since 1 kW = 1.34102 hp

6.86kW will be = (6.86 × 1.34102) hp

= 9.199 hp

7 0
3 years ago
What is the answer of this question please tell me <br><br>dadada please please​
charle [14.2K]

lol i neeeeeeeeeeeeeeeeeeeeeeeed pointssssssssssssssss

6 0
3 years ago
Consider an area-source box model for air pollution above a peninsula of land. The length of the box is 15 km, its width is 80 k
In-s [12.5K]

Consider an area-source box model for air pollution above a peninsula of land. The length of the box is 15 km, its width is 80 km, and a radiation inversion restricts mixing to 15 m. Wind is blowing clean air into the long dimension of the box at 0.5 m/s. On average, there are 250,000 vehicles on the road, each being driven 40 km in 2 hours and each emitting 4 g/km of CO.

Required:

a. Estimate the steady-state concentration of CO in the air. Should the city be designated as "nonattainment" (i.e., steady-state concentration is over the NAAQS standard)?

b. Find the average rate of CO emissions during this two-hour period.

c. If the windspeed is zero, use the formula to derive relationship between CO and time and use it to find the CO over the peninsula at 6pmConsider an area-source box model for air pollution above a peninsula of land. The length of the box is 15 km, its width is 80 km, and a radiation inversion restricts mixing to 15 m. Wind is blowing clean air into the long dimension of the box at 0.5 m/s. On average, there are 250,000 vehicles on the road, each being driven 40 km in 2 hours and each emitting 4 g/km of CO.

Required:

a. Estimate the steady-state concentration of CO in the air. Should the city be designated as "nonattainment" (i.e., steady-state concentration is over the NAAQS standard)?

b. Find the average rate of CO emissions during this two-hour period.

c. If the windspeed is zero, use the formula to derive relationship between CO and time and use it to find the CO over the peninsula at 6pmConsider an area-source box model for air pollution above a peninsula of land. The length of the box is 15 km, its width is 80 km, and a radiation inversion restricts mixing to 15 m. Wind is blowing clean air into the long dimension of the box at 0.5 m/s. On average, there are 250,000 vehicles on the road, each being driven 40 km in 2 hours and each emitting 4 g/km of CO.

Required:

a. Estimate the steady-state concentration of CO in the air. Should the city be designated as "nonattainment" (i.e., steady-state concentration is over the NAAQS standard)?

b. Find the average rate of CO emissions during this two-hour period.

c. If the windspeed is zero, use the formula to derive relationship between CO and time and use it to find the CO over the peninsula at 6pm

<em><u>p</u></em><em><u>lease</u></em><em><u> mark</u></em><em><u> me</u></em><em><u> as</u></em><em><u> brainliest</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em>

<em><u>f</u></em><em><u>ollow</u></em><em><u> me</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em><em><u>,</u></em><em><u>.</u></em><em><u>.</u></em><em><u>.</u></em>

3 0
3 years ago
Technician A says that the carpet padding is designed to help reduce noise and vibrations.
Firdavs [7]

Answer:

Technicians A is right for the answer

4 0
2 years ago
True or false? if i were to hook up an ac voltage source to a resistor, the voltage drop across the resistor would be in phase w
hodyreva [135]

Answer: True

Explanation:

4 0
2 years ago
Other questions:
  • Find the thickness of the material that will allow heat transfer of 6706.8 *10^6 kcal during the 5 months through the rectangle
    8·1 answer
  • Drag each tile to the correct box.
    15·1 answer
  • Find values of the intrinsic carrier concentration n for silicon at –70° 0° 20° C, 100° C, and C. At 125° each temperature, what
    14·1 answer
  • Yooo. does anyone have tin foil and tape mask that they can take a picture of and send it ?
    5·1 answer
  • You are hired as the investigators to identify the root cause and describe what should have occurred based on the following info
    9·1 answer
  • Explain what the engineering team should advise in the following scenario.
    7·1 answer
  • What Is Photosynthesis ?​
    7·2 answers
  • A 1020 Cold-Drawn steel shaft is to transmit 20 hp while rotating at 1750 rpm. Calculate the transmitted torque in lbs. in. Igno
    6·1 answer
  • What is the placement of a lock out device on an energy isolating device?.
    12·1 answer
  • An American architect whose principles of building included consonance with the landscape was ____________________________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!