Write a program to take a depthin Kilometersinside the earth

Write a program to take a depth(in Kilometers)inside the earth as input data; compute and display the temperature at this depth in degree Celsius and degrees Fahrenheit. The relevant formulas are

Celsius = 10 (depth) + 20

Fahrenheit = 1.8 (Celsius) + 32

Include two functions in your program. Function celsius_at_depth should compute and return the Celsius temperature at a depth measured in Kilometers. Function fahrenheit should convert a Celsius temperature to Fahrenheit.

(in c++ programming)

Solution

Here is the program for what you have given and please let me know if any errors occurs.

#include <stdio.h>

int

main(void)

{

double edepth;               

double celsius_at_depth;

double fahrenheit;

printf(\"Please enter the earth\'s depth in kilometers> \");

scanf(\"%lf\", &edepth);

celsius_at_depth = 10.0 * edepth + 20.0;

fahrenheit = 1.8 * celsius_at_depth + 32.0;

printf(\"The temperature at %5.2f km in Celsius is %5.2f C.\ \", edepth, celsius_at_depth);

printf(\"The temperature at %5.2f km in Fahrenheit is %5.2f F.\ \", edepth, fahrenheit);

return(0);

}

Write a program to take a depth(in Kilometers)inside the earth as input data; compute and display the temperature at this depth in degree Celsius and degrees Fa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site