rendered paste body#include <stdio.h>
#include <string.h>
float calcfah(float x)
{
return (x * 9/5) + 32;
}
float calccel(float x)
{
return (x - 32) * 5/9;
}
int main(void)
{
char choice[2];
float num = 0;
while ( (strcasecmp("q", choice)) != 0 )
{
printf("1. Convert Fahrenheit to Celsius.\n");
printf("2. Convert Celsius to Fahrenheit.\n");
printf("Q to quit.\n");
scanf("%s", &choice);
if ((strcmp("1", choice)) == 0)
{
printf("Please enter Fahrenheit number:");
scanf("%f", &num);
printf ("%g Degrees Celsius\n", calccel(num));
}
if ((strcmp("2", choice)) == 0)
{
printf("Please enter Celsius number:");
scanf("%f", &num);
printf ("%g Degrees Fahrenheit\n", calcfah(num));
}
}
return 0;
}