Temperature: 100 Unit: c
Temperature in Fahrenheit = 212.00
#include <stdio.h>
int main() {
float temp, converted;
char unit;
printf("Enter temperature value: ");
scanf("%f", &temp);
while (1) {
printf("Enter unit (C/F): ");
scanf(" %c", &unit);
if (unit == 'C' || unit == 'c') {
converted = (temp * 9 / 5) + 32;
printf("Temperature in Fahrenheit: %.2f Fn", converted);
break;
}
else if (unit == 'F' || unit == 'f') {
converted = (temp - 32) * 5 / 9;
printf("Temperature in Celsius: %.2f Cn", converted);
break;
}
else {
printf("Invalid unit! Please enter C or F.n");
}
}
return 0;
}
#include <stdio.h>
int main() {
float temp, converted;
char unit;
printf("Enter temperature value: ");
scanf("%f", &temp);
while (1) {
printf("Enter unit (C/F): ");
scanf(" %c", &unit);
if (unit == 'C' || unit == 'c') {
converted = (temp * 9 / 5) + 32;
printf("Temperature in Fahrenheit: %.2f Fn", converted);
break;
}
else if (unit == 'F' || unit == 'f') {
converted = (temp - 32) * 5 / 9;
printf("Temperature in Celsius: %.2f Cn", converted);
break;
}
else {
printf("Invalid unit! Please enter C or F.n");
}
}
return 0;
}