run time error

hi, i wrote the code for life, universe, and everything given in easy category. this is my first code in this codechef. i am getting run time error. what it means???
#include<stdio.h>
#include<conio.h>
int main()
{
int a[10],i;
printf("\n enter the numbers");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
i=0;
while(a[i]!=42)
{
printf("\nthe no.s %d",a[i]);
i++;
}

               getch();
               return 0;

}

can anyone help me to understand why run time error is coming???

Your program reads the first 10 numbers into an array. Then your program has a while loop that traverses the array and only stops when the array element is 42. If the first 10 numbers do not contain 42, the while loop will keep inspecting the array past its end, which causes a runtime error.

Some general advice:

  1. read the FAQ.
  2. read the problem statement carefully. Your program produces too much output and is based on assumptions about the input data that are not correct.

Good luck.

1 Like
//