Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. nbsp; Note: This appears on each machine/browser from which this site is accessed.
Decimal to binary: program examples
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. Decimal to binary: program examples
2. Program: decimal to binary
Let us look at a program to implement to algorithm for decimal to binary conversion.
The routine toBinary1 takes as input a value and returns the string representation in binary (base 2 )
The first part of the program will use the hard-coded value of 156 .
The second part will use a loop to output the decimal values and binary representations of the values from 0 to 16 .
3. Go code
Here is the Go code.
4. Go output
Here is the output of the Go code.
5. Java code
Here is the Java code.
6. Java output
Here is the output of the Java code.
7. JavaScript code
Here is the JavaScript code.
8. JavaScript output
Here is the output of the JavaScript code.
9. Lua code
Here is the Lua code.
10. Lua output
Here is the output of the Lua code.
11. PHP code
Here is the PHP code.
12. PHP output
Here is the output of the PHP code.
13. Python code
Here is the Python code.
14. Python output
Here is the output of the Python code.
15. Ruby code
Here is the Ruby code.
16. Ruby output
Here is the output of the Ruby code.
17. VBScript code
Here is the VBScript code.
18. VBScript output
Here is the output of the VBScript code.
19. End of page