I really need help with this question. Please explain? Also answer.
Given an int variable n that has already been declared , write some code that repeatedly reads a value into n until at last a number between 1 and 10 (inclusive) has been entered.
I really need help with this question. Please explain? Also answer.
Given an int variable n that has already been declared , write some code that repeatedly reads a value into n until at last a number between 1 and 10 (inclusive) has been entered.
It is kind of difficult to help you without giving the code away when the instructions are so clear and specific. But okay, let's review what you should already know:
- Write a program that declares an int variable named n and reads a value into it.
- Write another program that uses a while loop in some reasonable way, e.g., to loop from 0 to some integer greater than 0, printing the number on each iteration of the loop. (This particular pattern of logic would normally be done with a for loop, but for practice use a while loop.)
Can you write the two programs outlined above? If not, what problems are you facing?
If you can write the two programs outlined above, show your code. From there we can guide you to incorporate the two concepts into one program that does what your original question is asking you to do.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)