Answer:
#include<iostream>
using namespace std;
//define function to calculate the temperature in Celsius
float celsius_at_depth(float depth){
float celsius = 10 * (depth) + 20; //formula for calculation
return celsius;
}
//define function to calculate the temperature in Fahrenheit
float fahrenheit(float celsius){
float fahrenheit = 1.8 * (celsius)+ 32;//formula for calculation
return fahrenheit;
}
//main function program start from here
int main(){
//initialization
float depth;
print message
cout<<"Please enter the depth (in kilometers): ";
cin>>depth;
float cel = celsius_at_depth(depth); //Calling the function
float feh = fahrenheit(cel); //Calling the function
//print the outputs
cout<<"The Celsius temperature at depth in km: "<<cel<<endl;
cout<<"The temperature in Fahrenheit is: "<<feh<<endl;
}
Explanation:
Create function celsius_at_depth with return type float and a parameter. This function takes the value depth from the calling function and calculate the temperature in Celsius and then returns the result to the calling function.
create the second function Fahrenheit with return type float and with one parameter. This function takes the temperature input in Celsius and convert into Fahrenheit and then return to the calling function.
Create the main function and declare the variable.
print the message for the user and store the value enter by the user by using the instruction cin.
then, calling the function and store the return outputs.
Finally, print the output.