please help me in this simple problem


0
i am not able to understand what is the mistake i am doing in this program

In this line

if((a[j]==‘A’)||(a[j]==‘D’)||(a[j]==‘O’)||(a[j]==‘P’)||(a[j]==‘Q’**||)(**a[j]==‘R’))

{count=count+1;}

In second last expression || should be outside of brackets().

In if((a[j]==‘A’)||(a[j]==‘D’)||(a[j]==‘O’)||(a[j]==‘P’)||(a[j]==‘Q’||)(a[j]==‘R’)) take || out of the bracket.
Also take scanf for input to avoid buffer caused (scanf("%d\n",&t):wink: since after taking test case your program directly shows value 0. To get AC also in (cout statement) add newline.

Line no: 12
for(int j=0;a[j]!=’\0’;j++)

Line no: 14
(a[j]==‘Q’)||(a[j]==‘R’)

After you use cin>>t, there is a new line which is skipped by cin. When you use gets(a), it reads the newline character and thus, skips the first input of the string.
If the input by the user is:
1 ADIOPB (then enter)
Then gets(a) won’t skip the first string.

P.S. Avoid using gets(). Use fgets() to read data.