Brijmohan lal Sahu - Facebook
ads
ads

Thursday, October 30, 2014

Program to convert temperature automated with do while




---------------------------------------------------------------------

/* Program to convert Temperature Automated with do while */
#include<conio.h>
#include<iostream.h>
void main()
{
float c,f;
char ch;
int i;
clrscr();
cout<<"\n\t TEMPERATURE CONVERTER ";
cout<<"\n\tEnter :\n\t1.for F to C \n\t2.for C to F :";
cin>>i;
switch(i)
{
case 1:
do
{
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----------------------------------";
cout<<"\n\n\tEnter Y/y for more & N/n for exit :";
cin>>ch;
}while(ch=='Y' || ch=='y');
break;
case 2:
do
{
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-------------------------------------";
cout<<"\n\n\tEnter Y/y for more & N/n for exit:";
cin>>ch;
}while(ch=='y' || ch=='Y');
break;
default :
cout<<"\n\terror : wrong entry !!!!";
}
getch();
}

No comments:

Post a Comment