I submitted this code and the computer is telling me that I didn’t score a perfect 100 because I didn’t account for all testcases. How do I fix it?
#include
using namespace std;
int main()
{
int N, x;
cin>> N;
for (int i=0; i<N; i++)
{
cin>> x;
int sum=0;
int base=1;
int temp=x;
int last;
while (temp)
{
last=temp%10;
sum= sum+ (last*base);
temp=temp/10;
base = base*2;
}
cout << "decimal number =" << sum<< endl;
}
return 0;
}