C Program to Convert Celsius to Fahrenheit

Views: 947
Comments: 0
Like/Unlike: 0
Posted On: 20-Oct-2017 04:31 

Share:   fb twitter linkedin
reena
122 Points
12 Posts

Introduction

The logic of temperature conversion is converting mathematical formula to C expression. we can just convert mathematical formula of temperature in C language. Rest is simple input/output.

Formula

Fahrenheit = (9/5) * Celsius) + 32

Program

//C program to convert Celsius to Fahrenheit
#include <stdio.h>
#include <conio.h>

int main()
{
    float celsius, fahrenheit;

    printf("Please Enter temperature in Celsius: \n");
    scanf("%f", &celsius);

    // Convert the temperature from celsius to fahrenheit
    fahrenheit = ((celsius * 9)/5) + 32;
    // fahrenheit = ((9/5) * celsius) + 32;
    // fahrenheit = ((1.8 * celsius) + 32;

    printf("\n %.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit);
    getch();

    return 0;
}

Output

 

0 Comments
 Log In to Chat