Binary to decimal

It will be done using while loop and find remainder and multiply it with 2^i

Hi @kumarakash121005
Yes, just run a loop, keep extracting the digits and multiply them with 2^i and keep adding to final ans

u can refer this code -->

#include<iostream>
#include<math.h>
using namespace std;
int main() {
    int n;
    cin>>n;

    long long int ans = 0;
    int pos = 0;
    while(n > 0){
        int rem = n % 10;
        n = n / 10;
        ans += rem * pow(2,pos);
        pos++;
    }

    cout<<ans<<endl;
}

hi @kumarakash121005
is it clear or u still face any difficulty in this ques???