Holes in the text

Unable to find the error in the program as it runs successfully and give desired result on linux terminal. But “WRONG ANSWER” is shown after submission.
please help !

#include<stdio.h>
#include<string.h>

int main()
{
int holes=0,a,k,t,i;
char arr[100];
scanf("%d",&t);
if (t<=40)
{
for (i=0;i<t;i++)
{
scanf("%s",arr);
a = strlen ( arr ); ///////
a=a-1;
for (k=0;k<=a;k++)
{
if (arr[k]==‘B’)
holes = holes+2;

	else if ( arr[k]=='A' || arr[k]=='D' || arr[k]=='O' || arr[k]=='P' || arr[k]=='Q' || arr[k]=='R' )
	holes++;
	
	else continue;
	
}

printf("%d",holes);

}
}
return 0;

}

corrections:

  1. you forgot initialize holes to 0 for every test case,

  2. you have to print output in new line for each test case,

Just do the above correction and you’ll get AC. :slight_smile:

Here is your updated code.

put \n in printf. it will get accepted.

Two points you need to modify.

  1. Reset the count of holes, ( holes = 0 ) at each input string.
  2. Print the answer at a new line for each output.