C code for binary to decimal conversion 10


int main(){


long int binaryNumber,decimalNumber=0,j=1,remainder;

printf(“Enter any number any binary number: “);








printf(“Equivalent decimal value: %ld”,decimalNumber);

return 0;


Sample output:

Enter any number any binary number: 1101

Equivalent decimal value: 13




Binary number system: It is base 2 number system which uses the digits from 0 and 1.

Decimal number system:

It is base 10 number system which uses the digits from 0 to 9

Convert from binary to decimal algorithm:

For this we multiply each digit separately from right side by 1, 2, 4, 8, 16 … respectively then add them.

Binary number to decimal conversion with example:

For example we want to convert binary number 101111 to decimal:

Step1:  1 * 1 = 1

Step2:  1 * 2 = 2

Step3:  1 * 4 = 4

Step4:  1 * 8 = 8

Step5:  0 * 16 = 0

Step6:  1 * 32 = 32

Its decimal value: 1 + 2 + 4+ 8+ 0+ 32 = 47

That is (101111)2 = (47)10

Leave a comment

Your email address will not be published. Required fields are marked *

10 thoughts on “C code for binary to decimal conversion

  • Jacklyn Louck

    That is the proper weblog for anyone who wants to search out out about this topic. You realize so much its virtually exhausting to argue with you (not that I actually would want…HaHa). You undoubtedly put a brand new spin on a subject thats been written about for years. Great stuff, simply great!

  • Murray Bodkins

    Hiya, I’m really glad I’ve found this information. Nowadays bloggers publish only about gossips and web and this is really frustrating. A good website with exciting content, that is what I need. Thanks for keeping this web-site, I will be visiting it. Do you do newsletters? Can not find it.

  • Andrew Carmickel

    Howdy very cool site!! Man .. Beautiful .. Amazing .. I will bookmark your website and take the feeds additionally¡KI am happy to search out numerous helpful info here within the put up, we want work out extra techniques in this regard, thanks for sharing. . . . . .

  • Breanna Treider

    Hey There. I found your blog using msn. This is an extremely well written article. I’ll be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will definitely comeback.

  • Hai Marchionni

    you’re in reality a just right webmaster. The web site loading velocity is incredible. It kind of feels that you are doing any distinctive trick. Furthermore, The contents are masterpiece. you have performed a excellent job in this matter!

  • Berry Donate

    hey there and thank you for your info – I’ve certainly picked up something new from right here. I did however expertise a few technical points using this site, as I experienced to reload the website many times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I’m complaining, but slow loading instances times will very frequently affect your placement in google and can damage your high-quality score if ads and marketing with Adwords. Well I’m adding this RSS to my email and could look out for a lot more of your respective fascinating content. Ensure that you update this again very soon..