finding runtime error in Life, the Universe, and Everything

include<stdio.h>

void main ()
{ int i;
int a[5];
for (i=0;i<5;i++)
{ scanf ("%d",&a[i]);
}
for(i=0;i<5;i++)
{
if(a[i]==42)
break;
printf ("%d\n",a[i]);
}} 

please help me in finding error.

I think the runtime error that you are getting is a NZEC runtime error.

*NZEC stands for Non Zero Exit Code. Usually, returning non-zero values from main() will cause this error. This happens if you omit a return 0; from main() in C.

So just add ,“return 0” statement at the end of the main function .

1 Like

Please use this post which is already for this problem.

Sorry to be soo random but I keep on getting wronge answer but my code is fine ? please help its for Life, the Universe, and Everything

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
Integer[] number = new Integer[5];
for(int i = 0;i<number.length;i++)
{
number[i] = sc.nextInt();
}

for(int count = 0; count < number.length; count++)
{
if(number[count] == 42)
{
break;
}else
{
System.out.println(number[count]);
}
}
}
}

@flower101: Why are you assuming there are max 5 numbers ?

//