Holes in the text

My code running well on my system & also giving the desired output,but when i am submitting it gives me wrong answer.Can somebody tell me why i am getting his error.

Here is link to my code:–>

http://www.codechef.com/viewsolution/5944445

Thanks in Advance

You are storing output of every test case in an array k[]. The very first thing wrong in your code is :

for(j=0;j<9;j++)
k[i]=count;

Why you need this? You get output f a particular test case as count, then you want that k[i]= count. So, why are you putting that for loop?

Second thing wrong in your code is, you have taken size of k as 10 i.e. k[9]. That means k can only store at max 10 numbers. Thus, when the number of test cases exceed 10, what will happen, it’ll not store further answers, but will just print the garbage value when you display the output in the end.

See this test case and its output :

12
Q : 1
E : 0
A : 1
B : 2
C : 0
W : 0
Q : 1
E : 0
CODECHEF : 2
BBBBB : 1145258561  // garbage value
PQOQD : 1212630597  // garbage value
ABCDEFGHIJKLMNOPQRSTUVWXYZ : 8

You can simply do it this way without using this k[] array:

for(i=0;i<t;i++)
{
	scanf("%s",a);
	for(j=0;j<strlen(a);j++)
	{
		b=(int)a[j];
		if(b==65 || b==68 ||b==79 ||b==80  || b==81 || b==82)
			count++;
		else if(b==66)
			count+=2;
		else
			count+=0;
	}
	//for(j=0;j<9;j++)
	//	k[i]=count;
	print("%d\n",count);
	count=0;
}