In every problem where there is an endl function required in output, the testcases give wrong answers. I think its because I don’t see the cursor moving to new line in the output.
No endl seen in output screen
Hey Dhruv, you can test you code on online ide if you are not able to see if endl is working properly for getting your output or not.
And the code in the link you have shared first no. of test cases are coming and then the corresponding input is coming for given number of test cases.
you can correct this code in this way:
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int sum=0,p=1;
while(n>0){
sum=sum+(p*(n%10));
n=n/10;
p=p*2;
}
cout<<sum<<endl;
}
Thank you Sanjeet, the code works correctly now.