Write a complete C program to take a depth (in kilometers) inside the earth as input data;compute and display the temperature at this depth in degrees Celsius and degrees Fahrenheit. The relevant formulas are Celsius = 10 (depth) + 20 (Celsius temperature at depth in km) Fahrenheit = 1.8 (Celsius) + 32 Write this program using two different functions - - one function "celsius_at_depth" should compute and return the Celsius temperature at a depth measured in kilometers.The second function "fahrenheit" should convert a Celsius temperature to Fahrenheit. You don't have to use pointers to pass the data to the function(s). This is just to begin to understand, in general, what a function is, why use them, how to use them. see my attached example for a very simple program with a function. ---------------------------------------------------------------------------Example----------------------------------------------------------------------------------------- #include int calc(int x, int y); int main(void) { int num1, num2; printf("Enter 2 numbers to be added together : "); scanf("%d %d", &num1, &num2); printf("\nThe answer to x + y is : %d", calc(num1, num2)); return 0; } int calc(int x, int y){ int z; return(z=x+y); } ---------------------------------------------------------------------------Example-----------------------------------------------------------------------------------------
Write a complete C program to take a depth (in kilometers) inside the earth as input data;compute and display the temperature at this depth in degrees Celsius and degrees Fahrenheit. The relevant formulas are
Celsius = 10 (depth) + 20 (Celsius temperature at depth in km)
Fahrenheit = 1.8 (Celsius) + 32
Write this program using two different functions - - one function "celsius_at_depth" should compute and return the Celsius temperature at a depth measured in kilometers.The second function "fahrenheit" should convert a Celsius temperature to Fahrenheit.
You don't have to use pointers to pass the data to the function(s). This is just to begin to understand, in general, what a function is, why use them, how to use them. see my attached example for a very simple program with a function.
---------------------------------------------------------------------------Example-----------------------------------------------------------------------------------------
#include <stdio.h> int calc(int x, int y); int main(void) { int num1, num2; printf("Enter 2 numbers to be added together : "); scanf("%d %d", &num1, &num2); printf("\nThe answer to x + y is : %d", calc(num1, num2)); return 0; } int calc(int x, int y){ int z; return(z=x+y); }
---------------------------------------------------------------------------Example-----------------------------------------------------------------------------------------
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images