Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

Help me guys with this simple c++. I am a beginner and i need to check if this is functional because i haven't installed a compiler yet on my computer. #include #include main() { int F,C; clrscr(); printf("Fahrenheit: "); scanf("d%",&F); C=(5/9)*(F-32); printf("Celsius: d%", &C); getch(); }

OpenStudy (anonymous):

in c++.,the code is like this.. save this (.cpp) #include<iostream.h> #include<conio.h> main() { int F,C; clrscr(); cout<<"Fahrenheit: "; cin>>F; C=(5/9)*(F-32); cout<<"Celsius: d%", &C; getch(); }

OpenStudy (anonymous):

I thought the .h was unnecessary for modern C++ compilers.

OpenStudy (anonymous):

must be using an older C++... you didn't have \[\small{\text{using namespace std}}\]in there.

OpenStudy (anonymous):

Also, shouldn't the format specifier be %d instead of d%? Why would you have the address operator when you're interpolating the value of the variable C, and not it's address?

OpenStudy (anonymous):

try using standard C++ functions and methods like cout, cin, and cin.get() instead of something from C like printf() and getch()

OpenStudy (anonymous):

http://codepad.org/SepoxHFe

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!