Life, the Universe, and Everything

#include
using namespace std;
int main() {
int n;
while(1)
{
cin>>n;
if(n>0 && n<100)
{
if(n==42)
break;
else
cout<<n<<endl;
}
else
break;
}
// your code goes here
return 0;
}
why I am getting wrong answer while submitting can any one explain

There is no need to check for any conditions on n, firstly.
Secondly, you also need to change lines after every output.