Blog Archive

Sunday, August 29, 2010

Convert temperature from degree centigrade to Fahrenheit and vice versa using switch

/*
Convert temperature from degree centigrade to Fahrenheit and vice
versa using switch

*/
#include<conio.h>
#include<stdio.h>

void main()
{
float value;
int choice;
clrscr();
printf("Enter Your Choice. \n1 For Degree Centigrade To Fahrenheit. \n2 For Fahrenheit To Degree Centigrade");
scanf("%d",&choice);
if(choice==1)
{
printf("Enter Tempreture In Degree Centigrade.");
scanf("%f",&value);
value = (value*1.8)+32;
printf("Tempreture Is %2f F",value);
}
else if(choice ==2)
{
printf("Enter Tempreture In Fahrenheit.");
scanf("%f",&value);
value = (value-32)/1.8;
printf("Tempreture Is %2f C",value);

}
else
{
printf("Invalid Choice.");
}
}

No comments:

Post a Comment