C Program Celsius to Fahrenheit

Ram Pothuraju

This C program is for the conversion of Fahrenheit to Celsius and reverse. 

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
 clrscr();
 int a;
 float f,c;
 printf("To convert Fahrenheit into Celsius press 1\n");
 printf("To convert Celsius into Fahrenheit press 2\n");
 printf("Enter your choice:");
 scanf("%d",&a);
 switch(a)
 {
  case 1:
  printf("Enter value in Fahrenheit:");
  scanf("%f",&f);
  c=(f-32)/1.8;
  printf("%f Fahrenheit = %f Celsius",f,c);
  break;

  case 2:
  printf("Enter value in Celsius:");
  scanf("%f",&c);
  f=(1.8*c)+32;
  printf("%f Celsius = %f Fahrenheit",c,f);
  break;
  }
  getch();
}
Tags

Post a Comment

0Comments

Post a Comment (0)