41 lines
814 B
C
41 lines
814 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main() {
|
|
int u, d, c; /* Temperature Unit and # of Dergrees */
|
|
|
|
printf("Wheather\n");
|
|
|
|
printf("(1) Celcius -> Fahrenheit \n(2) Fahrenheit -> Celcius \n(1|2) ");
|
|
scanf("%d", &u);
|
|
|
|
/* Convert Celcius to Fahrenheit */
|
|
if (u == 1) {
|
|
printf("Celcius -> Fahrenheit\n");
|
|
|
|
printf("Enter temprature in Celcius: ");
|
|
scanf("%d", &d);
|
|
|
|
printf("Fahrenheit dergees = %.2f\n", d * 1.8 + 32); /* Fahrenheit Degrees */
|
|
}
|
|
|
|
/* Convert Fahrenheit to Celcius */
|
|
if (u == 2) {
|
|
printf("Fahrenheit -> Celcius\n");
|
|
|
|
printf("Enter temprature in Fahrenheit: ");
|
|
scanf("%d", &d);
|
|
|
|
printf("Celcius dergees = %.2f\n", (d - 32) / 1.8); /* Celcius Degrees */
|
|
}
|
|
|
|
if (u != 1 && u != 2) {
|
|
printf("Error: Invalid Argument\n");
|
|
|
|
exit(1);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|