# Help me in solving AOCP08 problem

### My issue

include <stdio.h>
int main()
{
int t,c1=0,c2=0,i;
scanf(“%d”, &t);

``````while(t--)
{
int A[10];
for(int i = 0; i < 10; i++)
{
scanf("%d", &A[i]);
}
for(i=0;i<=10;i+=2)
{
if(A[i]==1)
c1++;
}
for(i=1;i<=10;i+=2)
{
if(A[i]==1)
c2++;
}
if(c1>c2)
printf("%d\n",1);
else if(c2>c1)
printf("%d\n",2);
else
printf("%d\n",0);
}
``````

}
although i am getting correct output but it says wrong answer. Could it be a issue of data types??

### My code

``````// Update your code below to solve the problem

#include <stdio.h>
int main()
{
int t,c1=0,c2=0,i;
scanf("%d", &t);

while(t--)
{
int A[10];
for(int i = 0; i < 10; i++)
{
scanf("%d", &A[i]);
}
for(i=0;i<=10;i+=2)
{
if(A[i]==1)
c1++;
}
for(i=1;i<=10;i+=2)
{
if(A[i]==1)
c2++;
}
if(c1>c2)
printf("%d\n",1);
else if(c2>c1)
printf("%d\n",2);
else
printf("%d\n",0);
}
}

``````

Learning course: Beginner DSA in C
Problem Link: CodeChef: Practical coding for everyone

@chopper411
You must initialize c1 and c2 inside the while loop .