Code works on my compiler but doesn't get accepted

Here is the question - http://www.codechef.com/problems/TEST?page=1#comment-91684

Here is the code

import java.util.Scanner;

class y{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
while(in.nextInt() != 42){}return;

}

}

You donot seem to be outputting anything , while loop should be something like this

while(1>0)

{

n= sc.nextInt();

if(n!=42)

System.out.println( “” + n ) ;

else

break;

}

1 Like

@daaryan

You do not seem to be outputting anything

In your code

while(in.nextInt() != 42){
/* output the number from input here
followed by a new line*/
}