Temperature Conversion using Switch case


#include<stdio.h>
#include<conio.h>
int main()
{
int choice;
float k,c;
clrscr();
printf("enter initial scale of temperature\n 1. kelvin \t 2. celcius");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\n enter temperature in kelvin");
scanf("%f",&f);
c=k-273;
printf("\n the temperature in celcius is %f ",c);
break;
case 2:
printf("\n enter temperature in celcius");
scanf("%f",&c);
k=c+273;
printf("\n the temperature in kelvin is %f ",k);
break;
default:
printf("\n invalid initial scale");
}
getch();
return 0;
}


0 comments:

Post a Comment