Basic Do-While Loop

I'm suppose to make the do-while loop to output 0 to countLimit and assume the user is only putting in positive values.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main() {
   int countLimit = 0;
   int printVal = 0;

   // Get user input                                                            
   cin >> countLimit;

   printVal = 0; 
   do {
      cout << printVal << " ";
      printVal = printVal + 1;
   } while ( countLimit == 0 );
   cout << endl;

   return 0;
}


The Expected Output:
0 1 2 3 4 5
*********** *space*

My Output:
0
********

I can't get it to output a series.
look closely at line 15. what is countlimit after line 9?
A few things I have to say.

Always prompt the user, how do we know what to do?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;

int main(){

   int countLimit = 0;
   int printVal = 0;

   // Get user input    
   cout << "What we counting to? "; cin >> countLimit;
   
   printVal = 0;  //printVal set to 0
   do{
      cout << printVal << " ";  //Print the value
      countLimit--;                  //What is countLimit/?/5/4/3/2/1/0
      printVal = printVal + 1;  //Increment printVal/+/0/1/2/3/4/5
   }while (countLimit >= 0); //WHILE countLimit is NOT 0.... Do stuff!!
   

   system("pause");
}
This problem is on online workbook. Everything above the "while" I can't edit. I can only add in where the condition for the "while" is suppose to be.
Nevermind. I figured it out. Thanks guys.
Topic archived. No new replies allowed.