My problem is that being new to this whole thing of C++, my tutor want me to use a while-loop to display the contents of an array for numbers above or equal to 20. The above code I tried failed and throws errors. Any ideas or help?????
At line 6, although that's technically a legal way to declare two variables, that's an odd way of doing it. Is there any particular reason you're using a comma there? Do you understand what the comma means in C++?
At line 7, it's going to output the string "int b" to the standard output. Is that really what you intended?
At line 8, what are you trying to do? Because that line does nothing.
At line 9, your condition looks like it makes no sense. d is a pointer, not an integer value, because at line 6 you declared it to be an array of ints. Even if d were an int, you haven't initialised d or b, so they both contain undefined values. What's the point of comparing two undefined values?
Also, your while loop will only execute the code inside it if d is greater than b. However, inside that loop, you make d even greater (by incrementing it at line 11). Thus, d will never stop being bigger than b, so your loop will run infinitely.
(Well, actually, it will loop until d is the maximum possible value am int can hold, after which it will suddenly become very negative, and the loop will exit. Is that what you intended?)