Can u please tell me the logical error in the code

#include
#include
using namespace std;
int main() {
int n,N,deci_num=0;
cin>>n;
for(int i=0;i<=n;i++){
cin>>N;

    int a=0;
    while(N>0){
        int val=N%10;
        deci_num += (val*pow(2,a));
        a++;
        N=N/10;
        

    }

cout<<“number is”<<deci_num<<endl;
}

return 0;

}

hello @Aryan-Sharma-2421953867913946
pls share ur code using cb ide

1 Like

@Aryan-Sharma-2421953867913946
declare ur deci_number inside for loop.

check ur updated code here->

1 Like

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.