I'm not getting dowhile loops

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  int nLoopCount;
 cout << "Enter the amount of times you wish the program to loop. Make sure your input is greater than or equal to 1: "
          << "\n";
     cin >> nLoopCount;
  do
  {
     nLoopCount--;
     cout << "You have " << nLoopCount << " loops left. :D" << "\n";
  } while (nLoopCount <= 1);

  system("PAUSE");
  return 0;

}


So, here I am not sure what I am doing wrong. I am a beginner and am trying to learn the ways to become a successful programmer.
What I am trying to do here is have the user cin a value (whatever it is since i know it will run through the statment once without checking the condition) and have it keep looping if the statement is true. This would check if the statement is true at the end and keep going if it continues to be true (looping).
The outcome is that if any number is greater than 1, it will run through the statement only once and subtract one from the cin (nLoopCount). For instance, if i input 6, I would get 5. If it equals one,zero, or is negative the statement will keep subtracting into the negatives, never stopping.
Any help would be much appreciated! Thank you (all) so much!
Tell me what the condition of your do while loop is and when it would be true.
Last edited on
Well, first you are inputting how many times you want the loop to go for. Good.

Second, you are subtracting one from the LoopCount. That means if you enter "6", it will subtract one, and then say "You have 5 loops left. :D" because after subtract one from six you have five.

Now, I'm not going to give you the answer to this, but you should be able to figure it out pretty easily.
Look at this line

} while (nLoopCount <= 1);
Thank you all so much! Sorry, my condition that i think you were all hinting at was off. Thank you all for your time!
Topic archived. No new replies allowed.