My instructor asked me to create a conversion program for Temperature conversions, his goal was for us to learn how to use functions outside of the main function/program, otherwise this would have been easier for me I think. Lines 1-64 is my source code, the Last are the errors I receive.
Code:
#include <stdio.h>
void celsius(void); /*The celsius function in main */
void fahrenheit(void); /*The fahrenheit function in main*/
double get_celsius(void); /*Gets celsius temp from user*/
double c2f(double c); /*converts celsius to fahrenheit*/
void printFahrenheit(double f);/*prints the finished conversion*/
double get_fahrenheit(void);/*Gets fahrenheit from user*/
double f2c(double f);/*converts fahrenheit to celsius*/
void printcelsius(double c);/*prints the finished conversion to celsius*/
int main(void) /*Main Program*/
{
celsius();
fahrenheit();
return 0;
}
void celsius(void) /*celsius call function from main*/
{
get_celsius();
c2f(double c);
printFahrenheit(double f);
}
void fahrenheit(void) /*fahrenheit call function from main*/
{
get_fahrenheit();
f2c(double f);
printcelsius(double c);
}
double get_celsius() /*Input for C to F conversion*/
{
double c;
printf("Enter a temperature in Celcius for conversion.\n");
scanf("%lf", &c);
return 0.0;
}
double c2f(double c) /*Formula for C to F conversion*/
{ double f;
f = 32+9/5*c;
return 0.0;
}
void printFahrenheit(double f) /*Output for C to F conversion*/
{ printf("Temperature is %f \n", f);
}
double get_fahrenheit(void) /*Input for F to C conversion*/
{
double f;
printf("Enter a temperature in Fahrenheit for conversion.\n");
scanf("%lf", &f);
return 0.0;
}
double f2c(double f) /*conversion formula from F to C*/
{ c = (f-32)*5/9
return 0.0;
}
void printcelsius(double c) /*Output for F to C conversion*/
{
printf("Temperature is %f \n", c);
}
when I try to compile i get these errors : clang -ansi -pedantic -Wall -Wextra -W -Wmissing-prototypes -Wstrict-prototypes -Wconversion -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -fshort-enums -fno-common -Dinline= -g -DDEBUG -c "pa02.c"
Compilation failed.
pa02.c:27:9: error: expected expression
c2f(double c);
^
pa02.c:28:21: error: expected expression
printFahrenheit(double f);
^
pa02.c:34:9: error: expected expression
f2c(double f);
^
pa02.c:35:18: error: expected expression
printcelsius(double c);
^
pa02.c:61:5: error: use of undeclared identifier 'c'
{ c = (f-32)*5/9
^
5 errors generated.
My main concern is the "expected expression" errors, any help would be appreciated I've been stuck for hours. Thank you!