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

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.
#include
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;
Voters
Profile icon
PrestonHong
Comments
hotnewtop
Profile icon
Giothecoder

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
mwilki7

Change

while (initial <= reminder)

to

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
or
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
valya91

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 https://stemfixer.com/science-homework-help/