Skip to content

Instantly share code, notes, and snippets.

@CraigRodrigues
Last active July 29, 2016 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CraigRodrigues/4ca7793cfcce96219ed0674402840a90 to your computer and use it in GitHub Desktop.
Save CraigRodrigues/4ca7793cfcce96219ed0674402840a90 to your computer and use it in GitHub Desktop.
CS50x Coding Contest 2016 Practice - Temperature Converter
#include <math.h>
#include <stdio.h>
#include "cs50.h"
int main(void)
{
double num;
while (scanf("%lf", &num) == 1)
{
if (num < DBL_MAX || num >= -DBL_MAX)
{
double answer = num * 1.8 + 32;
printf("%.1f\n", answer);
}
else
{
printf("Enter a number between %f and %f degrees Celsius.", -DBL_MAX, DBL_MAX);
return 1;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment