#include
using namespace std;
int main()
{
int n;
int sum=0;
int p=1;
cin>>n;
while(n>0)
{
int no;
cin>>no;
int r=no%10;
sum=sum+(r*p);
p=p*2;
no=no/10;
}
cout<<sum<<endl;
n=n-1;
return 0;
}
WHY DOESN’T IT RUN?
#include
using namespace std;
int main()
{
int n;
int sum=0;
int p=1;
cin>>n;
while(n>0)
{
int no;
cin>>no;
int r=no%10;
sum=sum+(r*p);
p=p*2;
no=no/10;
}
cout<<sum<<endl;
n=n-1;
return 0;
}
WHY DOESN’T IT RUN?
Input will overflow, you need to use string for input.
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.