Docsity

Temperature Converter Program: Instructions and Usage, Exercises of Computer Engineering and Programming

Toggle sidebar
bg1
8
void main (void)
{
float c,f,k;
int ch;
clrscr();
printf ("\n\n\nWelcome to the temperature converter\n\n\n");
printf ("Please choose one of the temperature conversions you want\n");
printf ("\n\nIf you want to convert temperature from:\n\n\t\tCentigrades to
Farenheit and Kelvin please enter 1\n");
printf ("\n\t\tFarenheit to Centigrades please enter 2\n");
printf ("\n\t\tKelvin to Centigrades please enter 3\n");
printf ("\n\nEnter the choice:");
scanf ("%d",&ch);
switch (ch)
{
case 1:
{
printf ("\n\tPlease enter the temperature in Centigrades:");
scanf ("%f",&c);
k = c-273;
f = (c+32)*9/5;
printf ("\n\n\tThe temperature in Kelvin is: %f\n",k);
printf ("\n\n\tThe temperature in Farenheit is: %f\n",f);
break;
}
case 2:
{
printf ("\n\tPlease enter the temperature in Farenheit:");
scanf ("%f",&f);
c = (f-32)*5/9;
printf ("\n\n\tThe temperature in Centigrades is: %f\n",c);
break;
}
case 3:
{
printf ("\n\tPlease enter the temperature in Kelvin:");
scanf ("%f",&k);
c = k+273;
printf ("\n\n\tThe temperature in Centigrades is: %f\n",c);
break;
}}
getch();
}
Temperature
docsity.com

Partial preview of the text

Download Temperature Converter Program: Instructions and Usage and more Exercises Computer Engineering and Programming in PDF only on Docsity!

void main (void) { float c,f,k; int ch; clrscr(); printf ("\n\n\nWelcome to the temperature converter\n\n\n"); printf ("Please choose one of the temperature conversions you want\n"); printf ("\n\nIf you want to convert temperature from:\n\n\t\tCentigrades to Farenheit and Kelvin please enter 1\n"); printf ("\n\t\tFarenheit to Centigrades please enter 2\n"); printf ("\n\t\tKelvin to Centigrades please enter 3\n"); printf ("\n\nEnter the choice:"); scanf ("%d",&ch); switch (ch) { case 1: { printf ("\n\tPlease enter the temperature in Centigrades:"); scanf ("%f",&c); k = c-273; f = (c+32)9/5; printf ("\n\n\tThe temperature in Kelvin is: %f\n",k); printf ("\n\n\tThe temperature in Farenheit is: %f\n",f); break; } case 2: { printf ("\n\tPlease enter the temperature in Farenheit:"); scanf ("%f",&f); c = (f-32)5/9; printf ("\n\n\tThe temperature in Centigrades is: %f\n",c); break; } case 3: { printf ("\n\tPlease enter the temperature in Kelvin:"); scanf ("%f",&k); c = k+273; printf ("\n\n\tThe temperature in Centigrades is: %f\n",c); break; }} getch(); }

Temperature

docsity.com