Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- float T;
- float C, K, F;
- char P;
- printf("Zadana teplota:");
- scanf("%f", &T);
- printf("Jednotky:");
- scanf(" %c", &P);
- switch(P)
- {
- case 'c' :
- K = T + 273.15;
- F = C * 1,8 + 32.0;
- C = T;
- break;
- case 'C' :
- K = T + 273.15;
- F = C * 1,8 + 32.0;
- C = T;
- break;
- case 'k' :
- C = T - 273.15;
- F = C * 1,8 + 32.0;
- K = T;
- break;
- case 'K' :
- C = T - 273.15;
- F = C * 1,8 + 32.0;
- K = T;
- break;
- case 'f' :
- F = T;
- C = (F - 32.0) / 1.8;
- K = C * 1,8 + 32.0;
- break;
- case 'F' :
- F = T;
- C = (F - 32.0) / 1.8;
- K = C * 1,8 + 32.0;
- break;
- default :
- printf("Chybne zadané data.\n");
- }
- printf("Zadaná teplota: %.2f %c . \n", T, P);
- printf("Vysledne teploty:\n");
- printf("%.2f C. \n", C);
- printf("%.2f F. \n", F);
- printf("%.2f K. \n", K);
- }
Advertisement
Add Comment
Please, Sign In to add comment