Programming for Problem Solving (3110003)

BE | Semester-1   Winter-2019 | 07-01-2020

Q1) (c)

Implement a C Program to convert temperature from Fahrenheit to Celsius and vice versa. 

#include <stdio.h> 
void main()
{
    float c,f;
    printf("\nEnter the temperature in Celsius: ");
    scanf("%f",&c);
    f = (1.8 * c) + 32;
    printf("\nTemperature in Fahrenheit = %.2f\n",f);

    printf("\nEnter the temperature in Fahrenheit: ");
    scanf("%f",&f);
    c = (f-32) * (5/9);
    printf("\nTemperature in Celsius = %.2f\n",c);
}

Output:
Enter the temperature in Celsius: 0
Temperature in Fahrenheit = 32.00

Enter the temperature in Fahrenheit: 32
Temperature in Celsius = 0.00