{"id":10602,"date":"2022-11-19T07:30:21","date_gmt":"2022-11-19T07:30:21","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=10602"},"modified":"2023-11-01T11:12:53","modified_gmt":"2023-11-01T11:12:53","slug":"c-program-to-convert-binary-number-to-decimal-number","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/","title":{"rendered":"C Program to Convert Binary Number to Decimal Number"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\" alt=\"\" \/><\/p>\n<p>Within the realm of programming, the process of transforming binary numbers into decimal numbers serves as a vital operation, enabling data to be presented in a human-readable format. Binary numbers, constituting the base-2 numerical system, are typically denoted using only two symbols: 0 (zero) and 1 (one). On the other hand, decimal numbers adhere to the base-10 numerical system, utilizing digits spanning from 0 to 9 to represent numerical values.<\/p>\n<h2>What is Conversion from Binary To Decimal In C?<\/h2>\n<p>Conversion from binary to decimal in C means the user needs to convert a number that is in binary form to its value which will be in decimal form.<br \/>\nTake a break, lets discuss what are binary and decimal numbers then we will see the approaches to convert binary to decimal in c.<\/p>\n<h2>What is a Binary Number?<\/h2>\n<p>A binary number is characterized as a numerical representation within the binary system, also known as the base-2 numeral system. It conveys numeric values using a pair of distinct symbols: 1 (representing one) and 0 (representing zero).<\/p>\n<p><strong>Examples of Binary Numbers:<\/strong> 0101010, 111, 0010, etc.<\/p>\n<h2>What is a Decimal Number?<\/h2>\n<p>Decimal is a term that describes the base-10 number system, the most commonly used number system. The decimal number system consists of ten single-digit numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. The number after 9 is 10. The number after 19 is 20 and so forth.<\/p>\n<p><strong>Examples of Decimal Numbers:<\/strong> 1415, 1616, 472, etc.<\/p>\n<h2>Examples demonstrating Binary to Decimal in C<\/h2>\n<p>The following examples demonstrates the conversion of binary to decimal.<\/p>\n<p><strong>Example 1:<\/strong><\/p>\n<p><strong>Input:<\/strong> 111<br \/>\n<strong>Output:<\/strong> 7<br \/>\n<strong>Explanation:<\/strong> (122) + (121)+(1*20) = 4 + 2 + 1 = 7<\/p>\n<p><strong>Example 2:<\/strong><\/p>\n<p><strong>Input:<\/strong> 1010<br \/>\n<strong>Output:<\/strong> 10<\/p>\n<p><strong>Example 3:<\/strong><\/p>\n<p><strong>Input:<\/strong> 110<br \/>\n<strong>Output:<\/strong> 6<\/p>\n<h3>Approach 1: Conversion of Binary To Decimal In C using For Loop<\/h3>\n<p>In this approach, we are using the for a loop to convert binary to decimal in C language.<\/p>\n<p><strong>For Example:<\/strong><br \/>\nIf the binary number is 111.<br \/>\ndec_value = 1(2^2) + 1(2^1) + 1*(2^0) = 7<\/p>\n<p><strong>Algorithm of Binary To Decimal In C using for loop<\/strong><\/p>\n<ol>\n<li>Firstly, initialize the decimal_num variable with the value 0, add the binary number in the bin_num variable, and initialize rem.<\/li>\n<li>Start a for loop with condition i = 0, bin_num != 0, ++i.<\/li>\n<li>In the loop block,\n<ul>\n<li>Update the rem value to bin_num % 10.<\/li>\n<li>Change the value of bin_num with bin_num \/ 10.<\/li>\n<li>Atlast change the value of decimal_num with decimal_num + (rem) * (pow(2, i)).<\/li>\n<\/ul>\n<\/li>\n<li>At the end of the for loop, print the decimal_num variable, which has the value of the decimal number of the given binary number.<\/li>\n<\/ol>\n<p><strong>Code Implementation of For Loop approach for converting of Binary To Decimal In C<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_10640 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_10640 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_10640 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10640 .wpsm_nav-tabs > li.active > a, #tab_container_10640 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10640 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_10640 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_10640 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10640 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10640 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10640 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10640 .wpsm_nav-tabs > li > a:hover , #tab_container_10640 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_10640 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_10640 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_10640 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_10640 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_10640 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_10640 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_10640 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10640 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_10640 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10640 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_10640 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_10640\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10640\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_10640_1\" aria-controls=\"tabs_desc_10640_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_10640\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_10640_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;math.h&gt; \r\nint main()  \r\n{  \r\n    int i, bin_num, decimal_num = 0, rem;  \r\n    bin_num = 111;\r\n    for (i = 0; bin_num != 0; ++i)  \r\n    {  \r\n        rem = bin_num % 10;  \r\n        bin_num = bin_num \/ 10;  \r\n        decimal_num = decimal_num + (rem) * ( pow (2, i));  \r\n          \r\n    }  \r\n    printf (&quot;&#92;n Decimal Number of given binary number: %d&quot;, decimal_num);  \r\n    return 0;  \r\n}  \r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_10640 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_10640 a\"),jQuery(\"#tab-content_10640\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Time Complexity of C program to convert binary to decimal:<\/strong> The time complexity of this implementation of the conversion of binary to decimal in C language is O(logN).<\/p>\n<p><strong>Space Complexity of C program to convert binary to decimal:<\/strong> The space complexity of this implementation of the conversion of binary to decimal in C language is O(1).<\/p>\n<h3>Approach 2: Conversion of Binary To Decimal In C using Recursion<\/h3>\n<p>In this approach, we are using the recursive function to convert binary to decimal in C. BinarytoDecimal(strBinary, length) takes the input string and its size, and for each character convert it to decimal and multiply it with 2i. Add previous results to it.<\/p>\n<p><strong>Algorithm for the conversion of Binary To Decimal In C using recursion:<\/strong><\/p>\n<p>T1. ake the input string strBinary[] containing a binary number.<\/p>\n<ol start=\"2\">\n<li>Calculate its length using strlen(strBinary).<\/li>\n<li>Function BinarytoDecimal(strBinary, length) takes input and returns the number calculated using a recursive approach.<\/li>\n<li>If we are at the last character which is LSB, then return its decimal as it will be the same. (multiplied by 1 i.e 20 )<\/li>\n<li>Otherwise set temp=binary[i] \u2013 \u20180\u2019. It\u2019s a decimal value.<\/li>\n<li>Now multiply temp with 2len-i-1 using temp &lt;&lt; len \u2013 i \u2013 1.<\/li>\n<li>Add the result of other digits to temp using temp = temp + BinarytoDecimal(binary, len, i + 1).<\/li>\n<li>At the end of the recursion return temp.<\/li>\n<li>Print the calculated decimal in the main.<\/li>\n<\/ol>\n<p><strong>Code Implementation of Recursive approach for converting Binary to Decimal in C:<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_10641 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_10641 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_10641 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10641 .wpsm_nav-tabs > li.active > a, #tab_container_10641 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10641 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_10641 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_10641 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10641 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10641 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10641 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10641 .wpsm_nav-tabs > li > a:hover , #tab_container_10641 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_10641 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_10641 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_10641 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_10641 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_10641 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_10641 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_10641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10641 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_10641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10641 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_10641 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_10641\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10641\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_10641_1\" aria-controls=\"tabs_desc_10641_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_10641\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_10641_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include <stdio.h>\r\n#include <string.h>\r\nint BinarytoDecimal(char binary[],int len, int i){\r\n   if (i == len-1)\r\n   return (binary[i] - '0');\r\n\r\n   int temp=binary[i]-'0';\r\n   temp=temp<<len-i-1;\r\n   temp=temp+BinarytoDecimal(binary,len,i+1);\r\n   return (temp);\r\n}\r\nint main(){\r\n   char strBinary[] = \"111\";\r\n   int length=strlen(strBinary);\r\n   printf(\"Decimal Number of given binary number: %d\",BinarytoDecimal(strBinary,length,0));\r\n   return 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_10641 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_10641 a\"),jQuery(\"#tab-content_10641\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Time Complexity of C program to convert binary to decimal:<\/strong> The time complexity of this implementation of converting a binary number into a decimal number is O(logN).<\/p>\n<p><strong>Space Complexity of C program to convert binary to decimal:<\/strong> The space complexity of this implementation of converting a binary number into a decimal number is O(1).<\/p>\n<h3>Approach 3: Conversion of Binary to Decimal in C using Function<\/h3>\n<p>Let\u2019s Discuss the algorithm for converting binary to decimal in C language.<\/p>\n<ol>\n<li>A binary number is stored in the bin_num variable, and one other variable dec_num is initialized for storing the decimal number.<\/li>\n<li>BinaryTodecimal function will be called and bin_num is passed in it.<\/li>\n<li>In the function, decimal_num with 0, temp with 0, and rem are initialized.<\/li>\n<li>Then a while loop is started with the condition bin_num != 0.<\/li>\n<li>Inside the loop, the following steps will be done:\n<ul>\n<li>Change the value of rem to bin_num % 10.<\/li>\n<li>Change the value of bin_num to bin_num \/ 10.<\/li>\n<li>Change the value of decimal_num to decimal_num + rem * pow( 2, temp).<\/li>\n<li>Change the value of temp to temp++.<\/li>\n<\/ul>\n<\/li>\n<li>At last return the decimal_num variable.<\/li>\n<\/ol>\n<p><strong>Code Implementation for converting Binary to Decimal in C using Function:<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_10642 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_10642 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_10642 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10642 .wpsm_nav-tabs > li.active > a, #tab_container_10642 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10642 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_10642 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_10642 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10642 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10642 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10642 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10642 .wpsm_nav-tabs > li > a:hover , #tab_container_10642 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_10642 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_10642 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_10642 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_10642 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_10642 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_10642 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_10642 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10642 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_10642 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10642 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_10642 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_10642\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10642\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_10642_1\" aria-controls=\"tabs_desc_10642_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_10642\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_10642_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;stdio.h&gt;  \r\n\r\nint binaryTodecimal(int bin_num);  \r\nint main()  \r\n{  \r\n    int bin_num, dec_num;  \r\n    bin_num = 111;\r\n      \r\n    dec_num = binaryTodecimal (bin_num); \r\n    printf (&quot; Conversion of the binary number to decimal number is %d&quot;, dec_num);  \r\n    return 0;\r\n}  \r\n  \r\nint binaryTodecimal( int bin_num)  \r\n{  \r\n    int decimal_num = 0, temp = 0, rem;  \r\n    while (bin_num != 0)  \r\n    {  \r\n        rem = bin_num % 10;  \r\n        bin_num = bin_num \/ 10;  \r\n        decimal_num = decimal_num + rem * pow( 2, temp);  \r\n        temp++;  \r\n    }  \r\n    return decimal_num;  \r\n}  \r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_10642 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_10642 a\"),jQuery(\"#tab-content_10642\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Time Complexity of C program to convert Binary to Decimal:<\/strong> The time complexity of this implementation of converting a binary number into a decimal number is O(logN).<\/p>\n<p><strong>Space Complexity of C program to convert Binary to Decimal:<\/strong> The space complexity of this implementation of converting a binary number into a decimal number is O(1).<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nIn the realm of C programming, the conversion of binary numbers to decimal numbers is a fundamental task that enables the transformation of binary representations into their equivalent decimal values. This process is essential for various applications, particularly in scenarios where binary data needs to be interpreted or displayed in a human-readable format. We have explored different methods and approaches to achieve this conversion, providing valuable insights into the logic and techniques involved.<\/p>\n<h2>Frequently Asked Questions (FAQs) related to C Program to Convert Binary Number to Decimal Number<\/h2>\n<p>Here are some Frequently Asked Questions on \u201cHow to Convert Binary to Decimal Program in C\u201d.<\/p>\n<p><strong>1. Why is it important to convert binary numbers to decimal in C programming?<\/strong><br \/>\nConverting binary numbers to decimal is crucial for interpreting binary data and presenting it in a format that is easier for humans to understand. This is particularly valuable when working with low-level data or in scenarios where binary data needs to be converted for display or further processing.<\/p>\n<p><strong>2. What is the formula to convert a binary number to a decimal number?<\/strong><br \/>\nThe formula to convert a binary number to decimal involves multiplying each binary digit by the corresponding power of 2 and summing up the results. For example, to convert the binary number &quot;1010&quot; to decimal: (1 <em> 2^3) + (0 <\/em> 2^2) + (1 <em> 2^1) + (0 <\/em> 2^0) = 8 + 0 + 2 + 0 = 10.<\/p>\n<p><strong>3. Are there built-in functions in C for converting binary to decimal?<\/strong><br \/>\nC does not provide built-in functions specifically for this conversion, so custom logic is typically required.<\/p>\n<p><strong>4. What is the largest binary number that can be converted to decimal using this method?<\/strong><br \/>\nThe size of the binary number that can be converted to decimal using this method depends on the data type used to store the binary value. For example, with a 32-bit integer data type, you can convert binary numbers up to 2^32 &#8211; 1 to decimal.<\/p>\n<p><strong>Other C Programs<\/strong><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-calculate-percentage-of-5-subjects\/\">C program to calculate percentage of 5 subjects<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-add-two-numbers\/\">C program to add two numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-celsius-to-fahrenheit\/\">C program to convert celsius to fahrenheit<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-infix-to-postfix\/\">C program to convert infix to postfix<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-area-of-circle\/\">C program to find area of circle<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-roots-of-quadratic-equation\/\">C program to find roots of quadratic equation<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-reverse-a-number\/\">C program to reverse a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-merge-sort-for-linked-lists\/\">C program for merge sort for linked lists<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-performing-bubble-sort-on-linked-list\/\">C program for performing bubble sort on linked list<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-to-reverse-a-linked-list\/\">C program to reverse a linked list<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Within the realm of programming, the process of transforming binary numbers into decimal numbers serves as a vital operation, enabling data to be presented in a human-readable format. Binary numbers, constituting the base-2 numerical system, are typically denoted using only two symbols: 0 (zero) and 1 (one). On the other hand, decimal numbers adhere to [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-10602","post","type-post","status-publish","format-standard","hentry","category-c-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C Program to Convert Binary Number to Decimal Number<\/title>\n<meta name=\"description\" content=\"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C Program to Convert Binary Number to Decimal Number\" \/>\n<meta property=\"og:description\" content=\"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-19T07:30:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-01T11:12:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"C Program to Convert Binary Number to Decimal Number\",\"datePublished\":\"2022-11-19T07:30:21+00:00\",\"dateModified\":\"2023-11-01T11:12:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\"},\"wordCount\":1286,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\",\"articleSection\":[\"C Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\",\"name\":\"C Program to Convert Binary Number to Decimal Number\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\",\"datePublished\":\"2022-11-19T07:30:21+00:00\",\"dateModified\":\"2023-11-01T11:12:53+00:00\",\"description\":\"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C Programming\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/c-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"C Program to Convert Binary Number to Decimal Number\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C Program to Convert Binary Number to Decimal Number","description":"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/","og_locale":"en_US","og_type":"article","og_title":"C Program to Convert Binary Number to Decimal Number","og_description":"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.","og_url":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-11-19T07:30:21+00:00","article_modified_time":"2023-11-01T11:12:53+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"C Program to Convert Binary Number to Decimal Number","datePublished":"2022-11-19T07:30:21+00:00","dateModified":"2023-11-01T11:12:53+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/"},"wordCount":1286,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg","articleSection":["C Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/","url":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/","name":"C Program to Convert Binary Number to Decimal Number","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg","datePublished":"2022-11-19T07:30:21+00:00","dateModified":"2023-11-01T11:12:53+00:00","description":"Understand C Program to Convert Binary Number to Decimal Number with algorithm and Code in C language.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668839595189-C%20Program%20to%20Convert%20Binary%20Number%20to%20Decimal%20Number.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-binary-number-to-decimal-number\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"C Programming","item":"https:\/\/prepbytes.com\/blog\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"C Program to Convert Binary Number to Decimal Number"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=10602"}],"version-history":[{"count":7,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10602\/revisions"}],"predecessor-version":[{"id":18291,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10602\/revisions\/18291"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=10602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=10602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=10602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}