Tahamina_Taha

Menu Based Temperature conversion

Feb 5th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. //Menu Based Temperature conversion
  4.  
  5.  
  6. int main()
  7. {
  8.     int choise;
  9.     float f,c,cal;
  10.     printf("Temperature conversion menu \n");
  11.     printf("1.fahrenheit to celsius\n");
  12.     printf("2.celsius to fahrenheit\n");
  13.     printf("please enter your choice: ");
  14.     scanf("%d",&choise);
  15.     switch(choise){
  16.     case 1:{
  17.         printf("enter the fahrenheit temperature: ");
  18.     scanf("%f",&f);
  19.     cal=(f-32)*(5/9);
  20.     printf("the temperature in celsius is %f",cal);
  21.     break;
  22.  
  23.     }
  24.     case 2:{
  25.         printf("enter the celsius temperature: ");
  26.     scanf("%f",&c);
  27.     cal=(c*(9/5))+32;
  28.     printf("the temperature in fahrenheit is %f",cal);
  29.     break ;
  30.     }
  31.     default:
  32.         printf("not a correct option");}
  33.  
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment