Code works on my compiler but doesn't get accepted

Here is the question - TEST Problem - CodeChef

Here is the code

import java.util.Scanner;

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



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



n= sc.nextInt();


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




1 Like


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*/