Please check errror in the code for binary to decimal conversion

#include
#include
using namespace std;

int main() {
int n;
cin>>n;
int ans=0,count=0;
while(n>0){
int d=n&1;
ans=ans+(pow(2,count)*d);
n=n>>1;
count++;

}cout<<ans;

return 0;
}

ur input taking way is wrong u have to take a binary string as u have take input like
101 u are taking it as an integer not as a binary string so take a string not integer.
ex 101 will be treated as 101 as
not as binary like 5’