holes :getting wrong answer

#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
int test,i,len=0,count=0;

scanf("%d",&test);

while(test--)
{
	scanf("%s",&a);
	count=0;
	len=strlen(a);
	if(len<=100)
	{
		for(i=0;i<len;i++)
		{
			if(a[i]=='A'||a[i]=='D'||a[i]=='O'||a[i]=='P'||a[i]=='Q'||a[i]=='R')

				count++;
			if(a[i]=='B')
				count+=2;

		}
		printf("%d",count);

	}


}

return 0;

}

go for this

#include<stdio.h>

int main()
{
int t,i,j,k;
int count=0;
char a[100];
scanf("%d",&t);
if(t<=40)
{
for(i=1;i<=t;i++)
{
scanf("%s",a);
j=strlen(a);
if(j<100){
for(k=0;k<j;k++)
{
if(a[k]== โ€˜Aโ€™ || a[k]== โ€˜Dโ€™ || a[k]== โ€˜Oโ€™ || a[k]== โ€˜Pโ€™ || a[k]== โ€˜Qโ€™ || a[k]== โ€˜Rโ€™)
{
count++;
}
else if(a[k]==โ€˜Bโ€™)
{
count=count+2;
}
}
printf("%d\n",count);
count=0;
}
}
}

return 0;

}

@raghavyadavm: the problem is that you are not printing the next line after each output.

Here is the code here I have just added a โ€œ\nโ€ after printing the output. Got AC. I checked it in my accountโ€ฆ
HAPPY CODING

1 Like

@raghavyadavm: If you understood please accept some answer and close it