HOLES Getting WA

#include <stdio.h>

int main()
{
int t;
scanf("%d", &t);

fseek(stdin, 0, SEEK_END);

while (t--)
{
    char a[101];
    int i, numberOfHoles = 0;
    
    fgets(a, 100, stdin);
    
    for(i = 0; a[i] != '\0'; i++)
    {
        if(a[i] == 'A' || a[i] == 'D' || a[i] == 'O' || a[i] == 'P' || a[i] == 'Q' || a[i] == 'R')
        {
            numberOfHoles++;
        }
        else if(a[i] == 'B')
        {
            numberOfHoles += 2;
        }
    }
    
    printf("%d\n", numberOfHoles);
}

return 0;

}

Try using scanf("%s",a); for taking input of the string

remove the line:

fseek(stdin, 0, SEEK_END);

fgets(a, 100, stdin);

Try not to use gets() and fgets() unless absoutely necessary because you need to take the precautions to flush the buffer.

1 Like

Thanx a lot!!