Help me in solving LBCC21 problem

My issue

My code

#include <stdio.h>
int main() 
{
  int t;
  scanf("%d",&t); 
  while(t--)
  {
  int P;
  scanf("%d",&P);
  if(P<100)
  {
      printf("\n%d",P);
  }
  else if((P%100)<=10)
  {
      printf("\n%d",(P/100)+(P%100));
  }
  else
  {
      printf("\n-1");
  }
   }
return 0;
}

Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone

@nitheesha39
the p<100 then print is not right since u have only 10 question u can’t score like 23, or any double digit >10

@dpcoder_007
I have changed that part to p<=10, but still, it displays my answer was wrong. Could you please tell me what part to be corrected in my code?

@nitheesha39
The condition would be (P/100) + (P%100) <=10
if its true print (P/100) + (P%100)
else
print -1

that’s the whole logic

1 Like

@dpcoder_007
Thank you.