Wednesday, 5 October 2016

converting temperature by switch

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
float c,f;
cout<<" 1 For farenhiet to celsius "<<"\n";
cout<<" 2 For celsius to farenhiet"<<"\n";
cout<<" ENTER YOUR CHOICE  "<<"\n";
cin>>a;
switch(a)
{
case 1:
 cout<<"enter the temp in farenhiet-:";
 cin>>f;
 c=(5*f-160)/9;
 cout<<"temp in celsius is -: "<<c;
 break;
case 2:
 cout<<"enter the temp in celsius -: " ;
 cin>>c;
 f=9/5*c+32;
 cout<<"temp in farenhiet is -: "<<f;
 break;
default:
 cout<<"invalid input";
 break;
 }
getch();
}

No comments:

Post a Comment