Design and test a C program to convert temperature in Fahrenheit to Celsius and vice versa
Fahrenheit to Celsius
Output#include <stdio.h>int main(){float celsius, fahrenheit;/* Input temperature in fahrenheit */printf("Enter temperature in Fahrenheit: ");scanf("%f", &fahrenheit);/* Fahrenheit to celsius conversion formula */celsius = (fahrenheit - 32) * 5 / 9;/* Print the value of celsius */printf("%.2f Fahrenheit = %.2f Celsius\n", fahrenheit, celsius);return 0;}
Celsius to Fahrenheit
#include <stdio.h>int main(){float celsius, fahrenheit;/* Input temperature in celsius */printf("Enter temperature in Celsius: ");scanf("%f", &celsius);/* celsius to fahrenheit conversion formula */fahrenheit = (celsius * 9 / 5) + 32;printf("%.2f Celsius = %.2f Fahrenheit\n", celsius, fahrenheit);return 0;}
Try but don't cry
0 Comments
Post a Comment