Program:-
#include <stdio.h>
void main()
{
float fh,cl;
int choice;
printf("1:Convert temperature from Fahrenheit to Celsius.");
printf("\n2:Convert temperature from Celsius to Fahrenheit.");
printf("\nEnter your choice (1, 2): ");
scanf("%d",&choice);
if(choice ==1)
{
printf("Enter temperature in Fahrenheit: ");
scanf("%f",&fh);
cl= (fh - 32) / 1.8;
printf("\nTemperature in Celsius: %.2f",cl);
}
else if(choice==2)
{
printf("Enter temperature in Celsius: ");
scanf("%f",&cl);
fh= (cl*1.8)+32;
printf("\nTemperature in Fahrenheit: %.2f",fh);
}
else
{
printf("\nInvalid Choice !!!");
}
}
OUTPUT :-
OUTPUT 1:
1:Convert temperature from Fahrenheit to Celsius.
2:Convert temperature from Celsius to Fahrenheit.
Enter your choice (1, 2): 1
Enter temperature in Fahrenheit: 200
Temperature in Celsius: 93.33
OUTPUT 2:
1:Convert temperature from Fahrenheit to Celsius.
2:Convert temperature from Celsius to Fahrenheit.
Enter your choice (1, 2): 2
Enter temperature in Celsius: 200
Temperature in Fahrenheit: 392.00
Program File:(click the following .c file to get the program file)
Comments
Post a Comment