I had to do a similar exercise in a CPP class a while back. Though this version has potential for disaster (namely a char entered as choice) it *might* offer something useful.
Code:
#include <stdio.h>
void fTOc(float);
void cTOf(float);
int main(void)
{
float userTemp;
int choice;
int control;
control = 0;
do
{
printf("1) Convert a temperature to Celsius\n");
printf("2) Convert a temperature to Fahrenheit\n");
printf("3) Quit\n\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch(choice)
{
case 1: printf("\nEnter the temp to convert: ");
scanf("%f", &userTemp);
fTOc(userTemp);
break;
case 2: printf("\nEnter the temp to convert: ");
scanf("%f", &userTemp);
cTOf(userTemp);
break;
case 3: control = 1;
break;
default: printf("\n%d is not a valid option.\n", choice);
break;
};
printf("\n");
}while(control == 0);
printf("\n\nUser ended program.");
return 0;
}
void cTOf(float temp)
{
printf("\n%.2f degrees Celsius is %.2f degrees Fahrenheit.\n", temp, (32 + temp * 1.8));
}
void fTOc(float temp)
{
printf("\n%.2f degrees Fahrenheit is %.2f degrees Celsius.\n", temp, (temp - 32) / 1.8);
}