+ 4
Why does it output strange numbers...
in my most recent code , when you try to convert numbers, the conversion works fine... but in the next line, it outputs "4620160"... what's with these numbers anyway? :/ I would appreciate your help... thx https://code.sololearn.com/cj41FDj2fO3m/?ref=app https://code.sololearn.com/cj41FDj2fO3m/?ref=app
3 Respostas
+ 3
Undeclared variables that aren't static can give undefined behaviour.
On SoloLearn this would be outputting the maximum value of the datatype.
Notice the functions you wrote are of type int, however they don't return a value!! 😰
This can be fixed by making the functions void. (Which is what it looks like you intended to do).
Then, you can just call the function instead of printing it's value.
Like:
case 'c':
tempCtoF(c);
break;
case 'f' :
tempFtoC(c);
etc...
The program works perfectly after that fix. Great code!
+ 6
the line/s
cout<< tempCtoF
cout<<tempFtoC
are the problem.
they have a return type of int but never return a value. thus a junk value is printed.
use void tempCtoF(int c) then tempCtoF; without a cout
or return a value using the return keyword.
+ 3
thx guys