
{"id":15959,"date":"2014-09-20T16:25:14","date_gmt":"2014-09-20T16:25:14","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15959"},"modified":"2014-09-20T16:25:14","modified_gmt":"2014-09-20T16:25:14","slug":"how-to-write-an-algorithm-to-do-a-binary-to-decimal-conversion","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/09\/20\/how-to-write-an-algorithm-to-do-a-binary-to-decimal-conversion\/","title":{"rendered":"How to write an algorithm to do a binary to decimal conversion ?"},"content":{"rendered":"<pre>\n\/* part of work copied from http:\/\/www.sanfoundry.com\/c-program-binary-number-into-decimal\/ *\/\n#include &lt;stdio.h&gt;\n\nbtd()\n{\nint num, binary_val, decimal_val = 0, base = 1, rem;\nprintf(\"Enter a binary number : \");\nscanf(\"%d\",&amp;num);\nbinary_val = num;\nwhile ( num &gt; 0 )\n{\nrem = num % 10;\ndecimal_val = decimal_val + rem * base;\nnum = num \/ 10;\nbase = base * 2;\n}\nprintf(\"The binary number is : %d \\n\",binary_val);\nprintf(\"It's decimal equivalent is: %d \\n\",decimal_val);\n}\n\n\/* http:\/\/numbermonk.com\/ *\/\n\/* remainder -- a part that is still to come to make things perfect\n(or make something working fully) *\/\n\/* http:\/\/www.mathsisfun.com\/definitions\/remainder.html *\/\n\/* \"num\" is considered as a number which has to be broken\ninto 10 pieces beacuse the resulting number is built\nusing a maximum of 10 building blocks.\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/* part of work copied from http:\/\/www.sanfoundry.com\/c-program-binary-number-into-decimal\/ *\/ #include &lt;stdio.h&gt; btd() { int num, binary_val, decimal_val = 0, base = 1, rem; printf(&#8220;Enter a binary number : &#8220;); scanf(&#8220;%d&#8221;,&amp;num); binary_val = num; while ( num &gt; 0 ) { rem = num % 10; decimal_val = decimal_val + rem * base; num = num \/ &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/09\/20\/how-to-write-an-algorithm-to-do-a-binary-to-decimal-conversion\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write an algorithm to do a binary to decimal conversion ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[141,46,78,91],"tags":[585],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15959"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=15959"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15959\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}