Saturday, August 20, 2011

Program to convert readed temperature from celsius to Fahrenheit or vice versa.

//Program to convert readed temperature from celsius to Fahrenheit  or vice versa.
#include<stdio.h>
#include<conio.h>
void main()
{
float temp,a;
char ch;
clrscr();
printf("Reading temperature according to your choice");
printf("\n if you want to enter temprature in celsius and want to convert it into Fahrenheit please enter \" c \"");
printf("\n if you want to enter temprature in Fahrenheit and want to convert it into Celsius please enter \" f \"");
label:
printf("\n Please enter your choice: ");
ch=getche();
switch(ch)
{
 case 'c':
 case 'C':
     printf("\nPlease enter the temperature:");
     scanf("%f",&temp);
     printf("\nYou have entered %f Celius",temp);
     a=(temp*180)/100+32;
     printf("\nAs your requirement %f Celsius is converted %f Fahrenheit",temp,a);
     break;
 case 'f':
 case 'F':
     printf("\nPlease enter the temperature:");
     scanf("%f",&temp);
     printf("\nYou have entered %f Fahrenheit",temp);
     a=((temp-32)/180)*100;
     printf("\nAs your requirement %f Fahrenheit is converted %f Celsius",temp,a);
     break;
 default:
     printf("\nYou have entered a wrong choice please make sure that you are entering the correct choice");
     printf("\nPlease press \"c\" to enter temperatue in Celsius or \"f\" in fahrenheit");
     goto label;
 }
printf("\n Wheather you want to perform more conversions if yes then enter \"Y\" else \"N\"");
printf("\n Please enter your choice: ");
ch=getche();
if(ch=='y'||ch=='Y')
 {
  goto label;
 }
 else
 {
   printf("\nThank you! Have a gud time");
 }
getch();
}

Previous Next Home
0 Comments
Comments

Leave a Comment

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Twitter Delicious Facebook Favorites More