thats not what the problem statement says… read the statement again.
You have some small numbers as input(limit not defined), you have take input continuously and simultaneously print the number with the condition that it is not equal to 42. Also you have to stop taking input when you encounter 42.
pseudocode:
take a number as input
run an infinite loop
check if number==42:
break
else
print the inputted number
take another input
When codechef checks your program, it does not run it only on the given inputs but other inputs as well.So, after which iteration input will be 42 you donot know.
You should first get well versed with the difference in the use of for,while and do-while loops. Then decide for which loop will useful here.