No matter what input I give this code, the format is messed up and the values do not match what they are supposed to:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <float.h>
#include <string.h>
double input1 = 0;
int main()
{
double celsius1, kelvin1, rankine1;
scanf ("%g", &input1);
celsius1 = ((5 *(input1 - 32))/9);
rankine1 = (input1 + 459.67);
kelvin1 = ((5*rankine1)/9);
printf("%g degrees Fahrenheit\n%g degrees Celsius\n%g degrees Kelvin\n%g degrees Rankine", input1, celsius1, kelvin1, rankine1);
return 0;
}
Here is the output for an input of -460.67
-460.67
1.62382e-314 degrees Fahrenheit
-17.7778 degrees Celsius
255.372 degrees Kelvin
459.67 degrees Rankine
C:\Users\rthom\source\repos\ConsoleApplication1\Debug\ConsoleApplication1.exe (process 20956) exited with code 0.
I am required to use %g on this assignment for all variables as well, so there is no way I'd be able to change that.
What I have tried:
I've tried initializing input1 outside and inside of main. I've also tried declaring the variable in main, but regardless of what I've done it hasn't worked. When I've initialized input1 inside main and removed the &, I receive a null pointer != result exception.