| | |
Hi Everyone, Have a C++ Problem.
![]() |
•
•
Join Date: Jan 2007
Posts: 1
Reputation:
Solved Threads: 0
Using C++, Allow a user to input a series of zeros' and one's. stored in an array representing a binary word.
Then display the word horizontally on one line of the screen.
Then the program finds the decimal equilivant on the screen.
I would like some pointers on solving this problem.
I've set the array to hold a binary word. There is a display to enter on zero's and ones up to eight. I am not sure converting binary to decimal, problem converting it to decimal.
Thank you.
MichaelB
Then display the word horizontally on one line of the screen.
Then the program finds the decimal equilivant on the screen.
I would like some pointers on solving this problem.
I've set the array to hold a binary word. There is a display to enter on zero's and ones up to eight. I am not sure converting binary to decimal, problem converting it to decimal.
Thank you.
MichaelB
Once you have the bit string it's pretty easy. You'll just need to loop from the least significant bit (the one whose value is 1, often the right-most one) through the string to the most significant bit (the one whose value is 2^n, corresponding usually to the left-most). If the bit at the current index is 1, add 2^i, where i is the current index. For finding powers of two, you could also use the left-shift operator (number << shiftAmt), which would pretty much be
1<<i for this case. Make sense? ![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the C++ Forum
- Previous Thread: software development project...
- Next Thread: C++ download!
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code codesamplerunwhilecommands coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph guess gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker listing loop looping loops map math matrix memory multiple news node output pointer port problem proficiency program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






