Skip to content

Instantly share code, notes, and snippets.

@CraigRodrigues CraigRodrigues/temperature.c Secret
Last active Jul 29, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.