URGENT SOLUTION REQUIRED .I am getting wrong answer for this code.help me

I have started on codechef with easiest problem Life,the universe ,everything problem http://www.codechef.com/problems/TEST

My solution to this is

#include<stdio.h>
int main()
{
int a[100];
int i,n=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
if(a[i]==42)
{
break;
}
else
{
printf("%d",a[i]);
printf("\n");
}
}
return(0);
}

The chef is telling me wrong answer .Can someone please point out my mistake in code.

They never said that they are going to give you 100 or less than 100 input. It could be more 101 or 100000, you never know ;).And follow the output format,every single digit should be printed in a new line,so you have to use \n.

Hint- you can use infinite loop :wink:

Happy coding and welcome to codechef :smiley: