our program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely… rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.
Here is my code below! I successfully wrote the program to output the number that the user imputted. Is there a way to write it so that after the user imputs 42, it doesnt output the other numbers that the user imputs, like the example above? I want the user to be able to imput numbers after they imput 42, but the program does not output those numbers. Right now, it just closes the console once the user imputs 42.
// Problem 1 = Life, the Universe.cpp : Defines the entry point for the console application.
int _tmain(int argc, _TCHAR* argv)
cin >> imput; //reads the first number
while(imput != 42) //Print out number that we just checked is NOT 42
cout << imput << endl;
cin >> imput;
Why does adding while (cin >> imput); stop processing imput after reading 42? Is there an "after" function in c++, so like "after this happen this happens"? That might be stupid sounding, but im just new to c++.