September 9th, 2012, 08:11 AM
Can anyone please give me a short program for code converting
(Decimal code to binary code) :confused:
Comments on this post
September 9th, 2012, 08:39 PM
Clearly, you need to post an attempt of some sort and explain the trouble you're having.
[/code] are essential for python code and Makefiles!
September 10th, 2012, 01:49 AM
Also, you need a precise specification of what "converting (Decimal code to binary code)" is supposed to mean.
All values are stored within the computer as binary code. Internally within a computer, there is no such thing as "decimal code", though there can be and are a number of ways to binarily encode decimal (eg, binary-coded decimal (BCD), packed decimal). Is that the "decimal code" that you need to convert to straight binary? Well then, you need to specify the exact format of that "decimal code"!
Now, values can be expressed in character strings, such as in "1234". Is that what you mean by "decimal code"? That is a very serious question that you need to ask and to answer for yourself and for anybody working on this with you. Now, if that is what you mean by "decimal code", then converting that to actual binary code is an extremely common task for where there is a standard library function, scanf().
Expressing a value in a character string also works for output strings as well as for input strings. printf allows you to output a value in decimal, hexadecimal, and octal, but not in binary. So if you want to convert an internal value to a character string that expresses that value in binary, then you need to specify that.
If you have no idea what precisely you need to do, how could you ever write a program to do it?