Return to Snippet

Revision: 65130
at October 27, 2013 13:05 by bhart


Initial Code
/****************************************************
* c2f.c 
*
* Computer Science 50
* Brendan Hart
*
* Converts Celsius into Fahrenheit
*
* Demostrates float data types, equations, math
*****************************************************/
 
#include <cs50.h>
#include <stdio.h>
 
int main(void)
{
    // ask temperature in Celsius
    printf("What is the temperature in Celsius?\n");
     
    // get temperature in Celsius 
    float c = GetFloat();
     
    // equation converts temperature in Celsius to Fahrenheit
    // declares variable f as temperature in Celsius
    float f = ((9.0 / 5.0)*c + 32.0);
     
    // prints results to .1 decimal appoximation
    printf("The temperature in Fahrenheit is %.1f degrees\n", f);
    return 0;
}

Initial URL


Initial Description
Celsius to Fahrenheit

Initial Title
Celsius to Fahrenheit

Initial Tags


Initial Language
C