Program to Convert Binary to Decimal

This article show the program to calculate decimal number from equivalent binary number,
convert from binary to decimal in C/C++. Let us discuss about binary and decimal number system.

Convert from Binary to Decimal
The decimal (base ten) numeral system has ten possible values (0, 1, 2,3,4,5,6,7,8, or 9). The binary (base two) numeral system has two possible values (0 or 1). Binary system is the internal language of electronic computers. That’s why any computer programmer must need to know how to convert a decimal to binary. Follow C++ code will convert a decimal number into binary number.

C or C++ Code to Convert Binary to Decimal

int main(){
    long int a,n,bin_numb,dec_digit,dec_numb=0,numb_base=0;
    cout<<" \" This pogram will  calculate Decimal number from rquivalent Binary number. \""<<endl<<endl;
    cout<<"What is the Binary number ?. Give a Binary number only."<<endl;     cin>>bin_numb;
    cout<<endl<<"You have given Binary number :"<<bin_numb<<endl;

        dec_numb=dec_numb + (dec_digit<<numb_base);
        numb_base=numb_base + 1;
    cout<<"Equivalent Decimal number is : "<<dec_numb;

Leave a Reply

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