[Tutorial 7] 10.Convert the given temperature in Celsius to Fahrenheit. T(°F) = T(°C) × 1.8 + 32
#include <stdio.h>
int main() {
float celsius, fahrenheit;
/* Input temperature in Celsius from the user*/
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
/* Convert Celsius to Fahrenheit*/
fahrenheit = celsius * 1.8 + 32;
This program prompts the user to enter a temperature in Celsius, then converts it to Fahrenheit using the formula T(°F) = T(°C) × 1.8 + 32, and finally displays the result. Compile and run this program in a C compiler.
int main() {
float celsius, fahrenheit;
/* Input temperature in Celsius from the user*/
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
/* Convert Celsius to Fahrenheit*/
fahrenheit = celsius * 1.8 + 32;
/* Display the temperature in Fahrenheit*/
printf("%.2f Celsius is equal to %.2f Fahrenheit\n", celsius, fahrenheit);
return 0;
}
printf("%.2f Celsius is equal to %.2f Fahrenheit\n", celsius, fahrenheit);
return 0;
}
This program prompts the user to enter a temperature in Celsius, then converts it to Fahrenheit using the formula T(°F) = T(°C) × 1.8 + 32, and finally displays the result. Compile and run this program in a C compiler.
Comments
Post a Comment