Skip to content

Instantly share code, notes, and snippets.

@gregmacfarlane
Last active November 14, 2015 16:29
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 gregmacfarlane/40f30bb653dbaa6fc086 to your computer and use it in GitHub Desktop.
Save gregmacfarlane/40f30bb653dbaa6fc086 to your computer and use it in GitHub Desktop.
Temperature converter in C
#import<stdio.h>
double convert_temp(double temp_f){
double temp_c;
temp_c = (temp_f - 32) * 5/9;
return(temp_c);
}
int main(){
double temp_f;
double temp_c;
printf("Enter the temperature in degrees farenheit:");
scanf("%lf", &temp_f);
temp_c = convert_temp(temp_f);
printf("The temperature in celsius is %f degrees.\n", temp_c);
if(temp_f > 80){
printf("It's pretty hot, you should bring water.\n");
}
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment