Jump to content

Programming Fundamentals/Variables/C

From Wikiversity

variables.c

[edit | edit source]
// 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

[edit | edit source]

Copy

See Also

[edit | edit source]