C program for temperature conversion using switch case
/* C program to convert Fahrenheit into Celsius and reverse using switch case */
#include"stdio.h"
float ctof(float c); // Function declaration / prototype
float ftoc(float f);
void main()
{
int num;
float cel, fah, result;
start : printf("\n\n\t\t\t Degree Conversion \n");
printf("\t\t\t ````````````````` \n");
printf("1. From Celsius to Fahrenheit. \n");
printf("2. From Fahrenheit to Celsius. \n");
printf("3. Exit \n");
printf("Enter your choice: ");
scanf("%d", &num);
switch(num)
{
case 1:
printf("Enter the temperature in Celsius: ");
scanf("%f", &cel);
result = ctof(cel); //function call
printf("Temperature in Fahrenheit is : %.2f \n", result);
break;
case 2:
printf("Enter the temperature in Fahrenheit: ");
scanf("%f", &fah);
result = ftoc(fah);
printf("Temperature in Celsius is : %.2f \n", result);
break;
case 3:
exit(0);
default:
printf("\n\nPlease choose anyone option.\n");
goto start;
}
}
// function definition
float ctof(float c)
{
float f;
f = (1.8*c) + 32;
return f;
}
float ftoc(float f)
{
float c;
c = 0.56*(f-32);
return c;
}
Read next: C Program to Convert Temperature Celsius to Fahrenheit
ReplyDeleteOcoacaeAcol-roBillings Patrick Herman https://marketplace.visualstudio.com/items?itemName=uncancaze.Chaos-Groove-gratuita-2021
ReplyDeleteonothmire
Wcontoatgo Mike Abeita https://www.waytofuture.in/profile/New-Star-Tiny-Model-Diana-Alias-Amber-Bathroom-41-VERIFIED/profile
ReplyDeletespicasalbut
WalloFsupp_e-Lafayette Crystal Smith link
ReplyDeletetusnewormza
Ycrysinmiko-1978 Susan Ortega link
ReplyDeletebapcompmondse
AnolatYvio_fu Diane Stubblefield Download now
ReplyDeleteDownload
Get it
dumbfvirfootpben