Objective: Use the square root function, a constant and output format control. T
ID: 3672280 • Letter: O
Question
Objective: Use the square root function, a constant and output format control. The distance to the horizon can be calculated, in metric units, using the formula: d = square root of h(2R + h) where h is the height of the observer (or rather his/her eyes) above sea level and R is the radius of the planet. All units in the formula are in meters. A lookout is in a crows nest. I need a C program to take the height that the lookout's eyes are above the water and output the distance, d, to the horizon. The earth's radius is 6,378.1 kilometers. Put in the program a constant, R, for the radius(km) of the earth. Provide a line or two to find the distance to the horizon, d. Remember that another include has to be added in order to use math functions. All measurements in the formula need to be in meters. Output the distance in kilometers. Output it to the nearest tenth by controlling the output format.Explanation / Answer
int main()
{
int R;h;
double d;
cout<<" enter R";
cin>>R;
cin>>h;
d=sqrt(h*(2*R+h))
cout<<d;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.