If you are solving the problem TEST , then in that problem it has not been mentioned that how many i/p are there in the test file. You just need to sptop processing when you encounter integer 42. Hence your code should go like:
//package easy; // it should be hidden as compiler can't find the package called easy.
import java.util.Scanner;
public class Life_universeandEverything //it shouldn't be public as mentioned by @betlista
{
public static void main(String args[])
{
//System.out.println("Enter a number"); // hide it as it doesn't follow o/p format.
//int a[]=new int[1000];//you don't know number of tests, better don't take an array.
int n;
Scanner s=new Scanner(System.in);
while((n=s.nextInt())!=42)
System.out.println(n); // o/p until you don't encounter integer 42.
}
}
Hello…
In C language,I am unable to understand where to store the list of numbers being entered by the user i.e. either array,or some other thing because array is not working over there. Kindly tell me the answer. Thanx in advance.