Brijmohan lal Sahu - Facebook
ads
ads

Thursday, October 30, 2014

Program for temperature conversion with menu using do while loop



----------------------------------------------------------
/* Program for temperature conversion with menu */

#include<conio.h>
#include<iostream.h>
void main()
{
float c,f;
char ch;
int i;
clrscr();
cout<<"\n\tTEMPERATURE CONVERTER ";
do
{
cout<<"\n\tEnter :\n\t1.for F to C \n\t2.for C to F :";
cin>>i;
switch(i)
{
case 1:
cout<<"\n\t[Fahrenheit to Celsius]";
cout<<"\n\tEnter temperature in F:";
cin>>f;
c=((f-32)*5)/9;
cout<<"\n\t----------------------------------";
cout<<"\n\tF="<<f<<"  equals to  C="<<c;
cout<<"\n\t----------------------------------";
break;

case 2:
cout<<"\n\t[Celsius to Fahrenheit]";
cout<<"\n\tEnter temperature in C:";
cin>>c;
f=((c*9)/5)+32;
cout<<"\n\t-------------------------------------";
cout<<"\n\tC="<<c<<"  equals to  F="<<f;
cout<<"\n\t-------------------------------------";
break;

default :
cout<<"\n\terror : wrong entry !!!!";
}
cout<<"\n\n\tEnter Y/y for more & N/n for exit :";
cin>>ch;
}while(ch=='Y' || ch=='y');

getch();
}

No comments:

Post a Comment