I need assistance in writing a program in C. I would appreciate your help. Pleas
ID: 3693164 • Letter: I
Question
I need assistance in writing a program in C. I would appreciate your help. Please don't offer solutions that include C++ or Java.
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: 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. 1. Put in the program a constant, R, for the radius(km) of the earth 2. 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. 3. Output the distance in kilometers. Output it to the nearest tenth by controlling the output format.Explanation / Answer
#include <stdio.h>
#include <math.h>
int main()
{
double d,h;
const double r=6378.1;
printf("enter height: ");
scanf("%lf",&h);
d=(h*(2*r*1000)*h);
d=(sqrt (d))/1000;
printf(" Distance is %.1f mts ",d);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.