C program to convert fahrenheit to celcius and vice versa.

 C program to convert Fahrenheit to Celcius                                   and vice versa.

                                            It is the best c programming application for beginners.

We know that,
                       (i)celcius=(fahrenheit-32)*5/9
                                          &
                      (ii)fahrenheit=(cel*9/5)+32


Now we will apply these formulas in the program:-

#include<stdio.h>
int main()
{
float cel,fahr;
int choice;
printf("Enter 1 for f to c and 2 for c to f\n");
printf("Enter the Choice:");
scanf("%d",&choice);
if(choice==1)
{
printf("Enter the temperature in Fahrenheit:");
scanf("%f",&fahr);
        cel=(fahr-32)*5/9;
        printf("Celsius=%f",cel);
    }
    else if(choice==2)
    {
    printf("Enter the temperature in Celsius:");
    scanf("%f",&cel);
    fahr=(cel*9/5)+32;
    printf("Fahrenheit=%f",fahr);
    return 0;
}
}

OUTPUT:-

(1)
Enter 1 for f to c and 2 for c to f
Enter the Choice:1
Enter the temperature in Fahrenheit:100
Celsius=37.777779

(2)
Enter 1 for f to c and 2 for c to f
Enter the Choice:2
Enter the temperature in Celsius:37
Fahrenheit=98.599998

For the programs which are not available in this blog that you can mention in the comment box, I will post that program in this blog.

Comments

Popular Posts