Answer wrong is given by this code

#include
#include
using namespace std;

int main() {

int n,N,s=0,p,x=0;
cin>>N;

for(int i=0;i<N;i++){
	cin>>n;
	while(n>0){
		
		n=n%10;
		p=pow(2,x);
		x++;
		s=s+p*n;
		n=n/10;
		
	}
		cout<<s<<endl;;
		
	
}



return 0;

}

this code giving wrong answer

hi @yashtripathi6969_0cd127807d833066 refer

#include <iostream>

using namespace std;
int bintodec(int nos){
    int base = 1;
	int decval =0;
	while(nos){
		int lastdig = nos%10;
		nos=nos/10;
		decval+= lastdig*base;
		base*=2;
	}
	return decval;
    
}
int main(){
    int N,nos;
    cin>>N;
    for (int i = 1;i<=N;i++){
        cin>>nos;
    	cout<<bintodec(nos)<<endl;
    }
}

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.