বুধবার, ৩ ফেব্রুয়ারী, ২০১৬

Convert Binary to Decimal by c++

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    int outcome = 0, i, n;
    cout << "Enter the binary number: ";
    cin >> n;
    for(i = 0; n > 0; i++)
    {
        if(n % 10 == 1)
            outcome += pow(2, i);
        n = n / 10;
    }
    cout << "The decimal number of " << n << " is : " << outcome << endl;
    return 0;
}

//ahemdshuvo969

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন