-
Help
Im trying to get this program to work, it stops at
else
WHat have i done wrong here, i want to be able to specifiy whether fahrenheit or celsius can be used.
Regards
#include <stdio.h>
int main()
{
float fahrenheit, celsius;
int a;
printf("Enter a value of 1 for Celsius, 2 for Fahrenheit:\n");
scanf("%d", &a);
if (a == 1)
printf("Enter a degrees in Celcius:\n");
scanf("%f",& celsius);
fahrenheit = 1.8*celsius + 32.0;
printf("Fahrenheit = %f\n", fahrenheit);
else
printf("Enter a degrees in Fahrenheit:\n");
scanf("%f", & fahrenheit);
celsius = (fahrenheit - 32) * 5 / 9;
printf("Celsius = %f\n", celsius);
return 0;
}
Popular pages
Recent additions