#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;
}
bipin2
3
@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
bipin2
4
@raghavyadavm: If you understood please accept some answer and close it