using namespace std;
int main() { int number;
while(number != 42) { cin >> number; cout << number << endl; } return 0;
}
The program runs fine on code blocks, I don't know why I'm getting wrong answer, I did exactly what I was told to do.
First, the number is uninitialized before being used in first comparison, which is an undefined behavior. Second, processing should be stopped after reading 42, without printing it.
Ok nevermind my answer was accepted