![]() |
|
#1
|
|||
|
|||
convert array of decimal to array of binaryI have written a program to convert an array of decimal Numbers to its binary.
input is an array of size 8 , input:input[3] cout put is an array of size 32, means each integer number in input should be represented as 4-bit in output. output: output[12] for example this program run as below: enter a string of NO 1 2 3 1000010011000000 this is wrong because it is showing the integer in reverse order, instead of showing 1 as 0001 it has showed 1000. would you please check my program and tell me what's wrong with it? CPP / C++ / C Code:
Last edited by LuciWiz : 01-Nov-2005 at 06:53.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
Re: convert array of decimal to array of binaryQuote:
Why is your first loop inputting 0 < 3 and your second 0 < 4? This will cause a problem. The reason you are outputting the values in reverse order is you generate each value and put it in the array in reverse order. But you output the value immediately. You want to do your ourput after you totaly load the 'b' array. Also note you never load b[0] since n counts from 4 to 1, not 3 to 0. Oh, and read the Guidelines please. __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#3
|
|||
|
|||
Re: convert array of decimal to array of binaryThank you so much for your help.
I changed the things which you have mentioned, and now the program is working properly. here is the modified program. Code:
|
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| convert char array into CString? | nasaiya | MS Visual C++ / MFC Forum | 11 | 22-Aug-2005 03:13 |
| template comiling problems - need expert debugger! | crq | CPP / C++ Forum | 1 | 01-Feb-2005 21:26 |
| Hex Result giving strange answers. | Rosdahale | C Programming Language | 6 | 07-Dec-2004 20:28 |
| Creating N string | gwk | C Programming Language | 3 | 20-Jul-2004 23:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The