Life, the Universe and everything code shows runtime error

i am writing a basic code for the Life,the universe and Everything problem and it runs on my compiler totally fine and when i use sample case as a custom input it again runs fine but when i try to run it using codechef ide it shows run time error as well as time limit exceeded. What may be the problem.
Code is:
using namespace std;

int main() {
// your code goes here
int n;
return 0;
Pls tell me what is the problem.

Link your submission instead

Try this instead :
int n;
while(cin >> n){
if(n == 42)return 0;
cout << n << endl;
Link to my submission.

your solution worked fine can you pls tell me what is the difference between mine and your solution.

Oh! listen now, In codechef, you have to provide custom input and click Run, if you just wanna check if it goes correct on sample test cases. And for submitting a solution, click Submit.

Your Code is Absolutely fine.

Something error

Run time error…

@shubhamraghav0 @riya264

i did the same what you are saying but it was not working i can show you the screenshot. but i am not able to upload one at this time. i will upload it afterwards. it was working fine on giving custom input but when i ran it gave Runtime error

You don’t get me, You haven’t submitted anything from your account


And here goes your AC code

Your n is not initialized to anything. You can declare it like int n = 1; and then it should work fine.

Go through this link :,reading%20in%20the%20number%2042.