Click here to Skip to main content
15,905,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++ program must:
1. not use cout more than twice;
2. declare one type int variable;
3. use cout to prompt the user to enter any decimal integer numeric value;
4. use cin obtain and store the user input value in the type int variable;
5. use cout to display the input value in decimal, octal, and hexadecimal using the following 10 format, where D represents the decimal value, O represents the octal value, and H represents the 11 hexadecimal value: D decimal = O octal = H hexadecimal For example, if the user were to enter 22 your program would display the following, all on one line: 22 decimal = 26 octal = 16 hexadecimal

What I have tried:

I have tried using functions. Please do not use functions. Make program as simple as possible and please comment.
Updated 6-Jul-16 23:23pm
[no name] 6-Jul-16 21:51pm    
And your question is? "Gimme code" will not go down well. Please read this:

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Share this answer
I have tried using functions. Please do not use functions. Make program as simple as possible and please comment.
Why not? Functions are good.
You task is pretty trivial, just pick a number from the user and then print out its representation using different basis. If you're allowed then you could use the strtol (see strtol - C++ Reference[^]) (or, in a more C++ apporach a stringstream[^] object). On the other hand writing yourself such simple conversion function is not a daunting task.
Share this answer
As already noted you will not get it done for you.

Assuming that you know how to use cout to print a string and cin to read an integer input, I can only guess that you don't know how to print the integer value in three different formats using a single cout statement.

This can be done using stream manipulators - C++ Reference[^]. For integers there are three to specify the base - C++ Reference[^].
Share this answer
To learn C/C++ basics, it is a good practice to read a reference book, it covers all aspects of the language.
The C Programming Language - Wikipedia, the free encyclopedia[^][^][^]

Pay attention to data formatting functionalities.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900