hello

i hope you can help me :icon_question:

i just want to know how to code binary value to decimal value using c++

im willing to wait for your response :)

thanks a lot

godspeed

Sorry, I can't understand your question.
Binary value... of what? The same counter-question about "to decimal value"...

Google is your friend if you bother to use it at all. Read this and this

nothing fancy, if you know how to convert a binary representation to decimal on paper...just implement that! i'd use a string to input 1's and 0's but you can use a long long or something using a simple algorithm to seperate digits:

#include <iostream>

using namespace std;

int main( void )
{
    long long num; int result = 0, pow = 1;
    cin >> num;
    while( num > 0 ) {
           result += ( num % 10 )*pow;
           pow <<= 1;
           num /= 10;
    }
    cout << result << endl;
    return 0;
}

thank you so much for responding

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.