// Online C++ compiler to run C++ program online
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int a;
cout<<"Enter the number";
cin>>a;
int answer = 0;
int i =0;
while(a!=0){
int bit = a % 10;
if(bit == 1){
answer = pow(2,i) + answer;
}
a = a/10;
i++;
}
cout<<answer;
return 0;
}
Thanks you for commenting your questions. I will see question and respond you.