Skip to content
Sign upLog in
← Back to Community
"Do your homework" assignment
Profile icon

I cannot seem to figure out how to use a count controlled loop to display a reminder to "do your homework" 'x' number of times prompted by the user.
using namespace std;

int main ()
int reminder;
int initial = 1;
cout << "How many times would you like to be reminded to do your homework? ";
cin >> reminder;

while (initial <= reminder) { cout << "Do your homework!" << endl; } system("pause"); return 0;
Profile icon
Profile icon

Or you could just use a for loop:

int main(){
cout << "how many times would you like to be reminded?\n";
int reminder;
cin >> reminder;
for( int count = 0; count < reminder; count++){
cout << "# " << count + 1 << ": ";
cout << "do your homework!\n";

Profile icon


while (initial <= reminder)


while (count <= reminder)

The program will leave the while loop only if
count <= reminder becomes a false statement

To make it a false statement, you either have to:
make count bigger than reminder inside the while loop
make reminder smaller than count inside the while loop

To make count bigger: count = count + 1 to make it bigger by 1
To make reminder smaller: reminder = reminder - 1 to make it smaller by 1

Make sure to set count = 1 at the beginning.

Profile icon

A count controlled loop is a loop that counts from a specific value to the maximum value. It is used to display a reminder to do your homework 'x' number of times.

If you still need help with your homework, we can help