Why is my code wrong challenges fundamentals 1 problem

#include
using namespace std;

int main(){

int n;
cin>>n;

int ans = 0;
int binary = 1;

while(n != 0){
    int ld = n%10;
    ans = ans + ld*binary;
    n = n/10;
    binary = binary * 2;
}
cout<<ans;
return 0;

}

u are not taking the input only properly… u have just taken input n but not he binary numbers… refer to my code https://ide.codingblocks.com/s/594722

Sir, I have understood my error in the code

shall i mark the doubt as resolved then???

yaa sir you can mark it resolved

Sir, but in your answer you are using arrays which haven’t thought yet as challenges fundamentals section comes after arrays.

ok. so u can refer this https://ide.codingblocks.com/s/594722
I have removed array part from this and done it directly…

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.