Two mistakes:
- Remove this line-
printf("Input:- \n");
- In question you have to print before coming 42. If 42 has come you have to break.
Like this:
if(n!=42)
printf("%d\n",n);
else
break;
solved SPOJ – Life, the Universe, and Everything