here is my code:
Code:
#include <stdio.h>
float FahrenheitToCelsius(float x);
float CelsiusToFahrenheit(float x);
int main()
{
float x;
int Choise;
start:
x = Choise = 0;
printf("Chose 1 Or 2 To Convert The Temperature:\n");
printf("1. FahrenheitToCelsius\n");
printf("2. CelsiusToFahrenheit\n");
printf("Choise: ");
scanf("%d", &Choise);
if(Choise == 1)
{
printf("\nPlease Enter A Temperature In Fahrenheit: ");
scanf("%f", &x);
printf("The Entered Temperature In Fahrenheit Is: %f\n", x);
printf("The Equivalent Temperature In Celsius Is: %f\n", FahrenheitToCelsius(x));
}
else
if(Choise == 2)
{
printf("\nPlease Enter A Temperature In Celsius: ");
scanf("%f", &x);
printf("The Entered Temperature In Celsius Is: %f\n", x);
printf("The Equivalent Temperature In Fahrenheit Is: %f\n", CelsiusToFahrenheit(x));
}
getchar(); // this getchar() is not doing the job in this case;
goto start;
}
float FahrenheitToCelsius(float x)
{
float C;
float F;
C = F = 0;
F = x;
C = (5.0/9.0)*(F-32.0);
return C;
}
float CelsiusToFahrenheit(float x)
{
float C;
float F;
C = F = 0;
C = x;
C = (5.0/9.0)*(F-32.0);
F = ((9.0/5.0)*C)+32.0;
return F;
}
might you please tell me why getchar() is not working as you said it should solve the problem, thank you.