Help in Codeforces problem a

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner s=new Scanner(System.in);
while(true)
{
int a=s.nextInt();
if(a==42)
{
break;
}
}
}
}

What,s wrong with this program

Please either format your code or link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Also - can you provide a link to the Problem? “Codeforces problem a” is hard to Google :slight_smile:

2 Likes

That is true. But this solution looks closely like that Life,Universe and Everything question from Codechef…
going by that logic you have to do at 17 (after if(a==42))

System.out.println(a);
1 Like

https://www.codechef.com/viewsolution/28042903
My Solution using your code…
you just forgot the output that’s all! :slight_smile:
(sorry for the delay it was stuck in submission queue)

1 Like