Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- double temp, C, F;
- char c;
- printf(" Input temperature and unit respectively, enter f if unit is fahrenheit and c if celsius:\n");
- scanf("%lf %c", & temp, & c);
- if (c == 'f') {
- C = (1. / 9.) * (5 * temp - 160);
- printf("The temperature is %lf celsius ", c);
- } else if (c == 'c') {
- F = (1. / 5.) * (9. * temp + 160);
- printf("The temperature is %lf fahrenheit ", F);
- } else printf("Invalid input");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement