I need to take a decimal base 10 number supplied by the user and convert it to binary. Is there an equation for this? What would the code look like?
I need to take a decimal base 10 number supplied by the user and convert it to binary. Is there an equation for this? What would the code look like?
There's a FAQ on bitwise operators you could always read. Or you could search the forum, since this gets asked all the time.
Quzah.
Hope is the first step on the road to disappointment.
With "convert" you think about printing out the binary digits? If so, look up bitwise operators and/or the modulo operator.
Just code what you do on paper.
input in decimal is x
while x is greater than 0
a is x%2
store a in char array
x is x/2
increment array index
end loop
***if your convert mean binary equivalent of decimal no.
Long time no C. I need to learn the language again.
Help a man when he is in trouble and he will remember you when he is in trouble again.
You learn in life when you lose.
Complex problems have simple, easy to understand wrong answers.
"A ship in the harbour is safe, but that's not what ships are built
for"