C Program Fahrenheit to Centigrade Conversion and vice versa

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
    clrscr();
    float fah, cen;
    char choice, ch;
     do
     {
          printf("\n 1.Centigrade to Fahrenheit Conversion \n");
          printf("\n 2.Fahrenheit to Centigrade Conversion\n");
          printf("\n 3.Exit\n\n");
          printf("\n Enter Your Choice : ");
          scanf("%c",&choice);
          switch(choice)
          {
            case '1' :
            printf("\n Enter temperature in Celsius : ");
            scanf("%f",&cen);
            fah=(1.8 * cen) + 32;
            printf("\n Temperature in Fahrenheit = %f",fah);
            break;
            case '2':
            printf("\n Enter temperature in Fahrenheit : ");
            scanf("%f",&fah);
            cen=(fah-32) / 1.8;
            printf("\n Temperature in Celsius = %f",cen);
            break;
            case '3' : exit(0);
                     break;
            default : printf("Wrong Choice..!!");
                     break;
          }
            printf("\n------------------------------------\n");
         }while(choice!=3 && choice!=getchar());
    getch();
}

Run:

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...