Holes gets vs cin

why gets doesnt takes input when it runs for the first time in a loop?

eg:-
#include
#include<stdio.h>
using namespace std ;

int main()
{
char a[100];
int t,c;
cin>>t;
while(t>0)
{
c=0;

            cin>>a;

             for(int i=0;a[i]!='\0';i++)
                { if((a[i]=='A')||(a[i]=='D')||(a[i]=='O')||(a[i]=='P')||(a[i]=='R')||(a[i]=='Q'))
                   c++;
                  if(a[i]=='B')
                   c=c+2;
                 }
cout<<c<<endl;
t--;
}
return 0;

}

The above code works

but if we replace cin with gets(a) the first case never works.
Why is this happening?

Because it reads the rest of the line after t in input…

If you want try to replace cin>>t with scanf("%d\n")