Monday , 24 July 2017
Home » Tutorials » C programming » C Program to Convert binary number to decimal number – Base conversion program

C Program to Convert binary number to decimal number – Base conversion program

#include < stdio.h >
#include < conio.h > 

void main()
{
 long n,dec,mult,r,base; 
 clrscr();
 printf("\n Enter a base : ");
 scanf("%ld",&base);
 printf("\n Enter a number :");
 scanf("%ld",&n); 
 dec = 0;
 mult=1;
 printf("\n Decimal equivalent of base %ld number %ld is ",base,n);
 while ( n != 0 )
 {
  r = n % 10;
  n /= 10;
  r = r * mult;
  dec = dec + r;
  mult *= base;
 } // while
 printf("%ld",dec);
}

 

About Rajeel

I'm Rajeel, a teen blogger from India who loves computers, sports, internet and all other kind of tech stuffs. This blog thing is one of my favourite hobby and the one that eats up much of my time. But Really, I'm loving it :) Find me in G+

Leave a Reply

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

*

Scroll To Top