#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
float fah, cen;
char choice, ch;
do
{
printf("\n 1.Centigrade to Fahrenheit Conversion \n");
printf("\n 2.Fahrenheit to Centigrade Conversion\n");
printf("\n 3.Exit\n\n");
printf("\n Enter Your Choice : ");
scanf("%c",&choice);
switch(choice)
{
case '1' :
printf("\n Enter temperature in Celsius : ");
scanf("%f",&cen);
fah=(1.8 * cen) + 32;
printf("\n Temperature in Fahrenheit = %f",fah);
break;
case '2':
printf("\n Enter temperature in Fahrenheit : ");
scanf("%f",&fah);
cen=(fah-32) / 1.8;
printf("\n Temperature in Celsius = %f",cen);
break;
case '3' : exit(0);
break;
default : printf("Wrong Choice..!!");
break;
}
printf("\n------------------------------------\n");
}while(choice!=3 && choice!=getchar());
getch();
}
Run:
Previous Next
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();
float fah, cen;
char choice, ch;
do
{
printf("\n 1.Centigrade to Fahrenheit Conversion \n");
printf("\n 2.Fahrenheit to Centigrade Conversion\n");
printf("\n 3.Exit\n\n");
printf("\n Enter Your Choice : ");
scanf("%c",&choice);
switch(choice)
{
case '1' :
printf("\n Enter temperature in Celsius : ");
scanf("%f",&cen);
fah=(1.8 * cen) + 32;
printf("\n Temperature in Fahrenheit = %f",fah);
break;
case '2':
printf("\n Enter temperature in Fahrenheit : ");
scanf("%f",&fah);
cen=(fah-32) / 1.8;
printf("\n Temperature in Celsius = %f",cen);
break;
case '3' : exit(0);
break;
default : printf("Wrong Choice..!!");
break;
}
printf("\n------------------------------------\n");
}while(choice!=3 && choice!=getchar());
getch();
}
Run:
Previous Next
No comments:
Post a Comment