Glad you got it worked out. You had your loop condition backwards, but didn't fix it properly, and the placement of your "invalid input" message is incorrect. Take a look at what you wrote:
Code:
do {
printf("Enter the number of items in the list (n):");
scanf("%d", &n);
} while (n > 0 && 10 >= n); {
printf("?Invalid input: Number must be between 1 and 10\n");
}
do loops don't have "else" type clauses. The invalid input statement would always be printed once the loop exits.
As for when the loop exits, remember, in C, your loops have "keep going" condition, i.e. the loop repeats so long as the loop condition is true. So your loop repeats while n is greater than 0 and less than or equal to 10. That means if the user inputs a valid number, from 1-10, you repeat and ask for more. The loop I gave was do...while input is not valid. You did do...while input is valid.
So then you switched the direction of the < and > signs, which doesn't give exactly the opposite logic. Switching the signs says repeat the loop while n is less than 0 and greater that or equal to 10. That is impossible. What you wanted was this:
Code:
do {
prompt user
read input
if (n <= 0 || n > 10)
print "invalid input..."
} while (n <= 0 || n > 10);
When you invert a < you get >=, and when you invert a <=, you get >. Inverting > and >= work similarly. Also, when you invert a logical statement with an && or an ||, you have to invert the logic of each half of the && or ||, and switch && for || or vice versa. This is called DeMorgan's Law. An example would probably be simpler:
Code:
// Assume I have a statement like this one
A && B
// if I want to invert it, I can do
!(A && B)
// but sometimes that is hard to read, so the following is more clear
!A || !B
// note that A and B are individually inverted, and that the && changed to an ||