TEST - Life, the Universe, and Everything
Your 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.
Input: 1 2 88 42 99 Output: 1 2 88
If you have some troubles with your code, you can take a look in the forum, you'll find the answer, only for this problem, in various languages.
|Added by:||Michał Małafiejski|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Resource:||Douglas Adams, The Hitchhiker's Guide to the Galaxy|
@adi_jalan ,check the input of only integer is accepted , I had the same problem when i used .scanner.hasnextint() the issue got resolved.
My code is running perfect on my pc. But here it is showing compilation error
check your header file ! :P
Nice problem for beginners to understand input and output.
@god_slayer, your loop takes in 1000 inputs. what if the user doesn't enter 1000 numbers, your program will be frozen there.
value wont be entered into 'a' since '&' symbol is not used for addressing in scanf keyword.a will be taken garbage value and loop will become infiite loop
brute force dont think just doLast edit: 2015-08-18 09:10:28
@isha_kiran , The problem is to print any random number entered except 42.Not the numbers less than or equal to 42. And when the user enters 42,the loop should break.Try rewriting the code :)
my code is giving correct output but here showing compilation error why???