# Thread: Need help on a fairly simple code

1. ## Need help on a fairly simple code

So the problem is that I have to get input from the user for the depth and then make that into Celsius and Fahrenheit using the formulas DC=10*Depth+20 and DF=1.8*DC+32 respectively. Here's what I've got so far, and it is picking up the Depth from the user, but I don't know how to make that depth carry to the functions below. It's not erroring and it keeps displaying 1.00 for the Depth (if I put 1), but 0.00 for both Celsius and Fahrenheit.

Thanks for the help in advance

Code:

Code:
```#include<stdio.h>

/*Function Prototypes*/
void convert_celsius(void); /*determines the degrees in Celsius*/
void convert_fahrenheit(void); /*Converts Celsius to Fahrenheit*/

/*Name: main*/
int
main(DegreesCelsius, DegreesFahrenheit)
{
double DepthInKm; /*depth inside earth in kilometers*/
/*get the depth in kilometers*/printf("EE 233 Fall 2012,P2: Depth to Celsius and Fahrenheit Conversion Program.\n\nEnter a depth in kilometers: ");
scanf("%lf", &DepthInKm);

/*compute the degrees in Celsius*/
convert_celsius(DepthInKm);

/*compute the degrees in Fahrenheit*/
convert_fahrenheit(DegreesCelsius);

/*display the result in a paragraph*/
printf("EE 233 Fall 2012,P2, dhc10, Daniel H. Camburn\n\nFor a depth of %.2f kilometers, the ", DepthInKm);
printf("temperature is %.2f degrees Celsius, and %.2f degrees Fahrenheit.\n", DegreesCelsius, DegreesFahrenheit);

return(0);
}

/*
*Determines degrees in Celsius at the given depth
*/
void
convert_celsius(DepthInKm)
{

double degrees_celsius; /*temperature in Celsius of the depth*/
degrees_celsius=(10*DepthInKm)+20;}

/*
*Converts Celsius to degrees Fahrenheit
*/

void
convert_fahrenheit(DegreesCelsius)
{
double degrees_fahrenheit; /*temperature in Fahrenheit of the depth*/
degrees_fahrenheit=(1.8*DegreesCelsius)+32;}
```

2. O_o

What language is that supposed to be?

If that is supposed to be C, then no it isn't "Depth" because it isn't compiling.

Look, just do yourself a favor and ignore this task for now; get and thoroughly study a good book ("The C Programming Language").

Soma

3. The argument lists in your function declarations; i.e.

Code:
`void convert_celsius(void); /*determines the degrees in Celsius*/`
... do not match the argument lists in your function definitions; i.e.

Code:
`void convert_celsius(DepthInKm)`
Furthermore, when you calculate the temperature in Celsius, then in Fahrenheit, you're not storing the results anywhere (the variables "DegreesCelsius" and "DegreesFahrenheit" remain unchanged).

Popular pages Recent additions