Van Neuman loves binary

This code is run in Sublime editor but when i submit it there it shows test cases failed.

#include
using namespace std;

int binary_to_decimal(int n)
{
int ans=0;
int rem=0,pow=1;

while(n>0){
	rem=n%10;
	ans+=rem*pow;
	pow*=2;
	n/=10;
}
return ans;

}

int main()
{
int n;
cin>>n;
while(n–){
int no;
cin>>no;
cout<<binary_to_decimal(no)<<endl;
}
return 0;
}

Hey @asif_h please share your code using ide.codingblocks.com so that i can help you in debugging it :grinning:

If you don’t know how to share your code using ide.codingblocks.com
Then use this
How to share link of the code in coding blocks ide?

I write in online ide of coding blocks and save it but in share options there is no option to share

It generates special url, you have to share that url

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.