Binary to decimal

#include
#include
using namespace std;

int main()
{
int n;
cin>>n;
int sum=0;
int a,b,i=0;
while(n>0){

	a=n%10;
	b=a*(2^i);
	sum=sum+b;
	i=i+1;
	n=n/10;
}
cout<<sum<<endl;

return 0;

}
//mistake?

hi @srivastavaayush1611_3fd51b257da0b834 ^ is the symbol for xor not power for x power y u have to write pow(x,y)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.