< Programming Fundamentals < Variables

variables.c

// This program converts a Fahrenheit temperature to Celsius.
//
// References
//     https://www.mathsisfun.com/temperature-conversion.html
//     https://en.wikibooks.org/wiki/C_Programming

#include <stdio.h>

int main() 
{
    float fahrenheit;
    float celsius;
    
    printf("Enter Fahrenheit temperature: ");
    scanf("%f", &fahrenheit);

    celsius = (fahrenheit - 32) * 5 / 9;

    printf("%f° Fahrenheit is %f° Celsius", fahrenheit, celsius);

    return 0;
}

Try It

Copy

See Also

This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.