The user is asked to type in a character and a number. The character will then be printed out that many times, but only 10 characters per line. If first they type in 7 and then the next time around they type in 12, only 3 can go on one line then 9 on the next. I'm not sure how to manipulate my program to do this.
while ( number > 0)
{
cout << endl;
cout << "please enter a positive integer" << endl;
cin >> number;
if (number > 0)
{
cout << "please enter a character" << endl;
cin >> character;
cout << endl;
for (int i = 1; i <= number; i++)
{
cout << character;
if (i % 10 == 0)
cout << endl;
}
}
Where would I put this in the while loop so that it doesn't mess up the rest of the program. And do I need to declare a different variable that is set equal to 10?
No, you would have one variable that would be 0. For every character you print, you add one to the variable. When the variable == 10, you print a newline, then carry on.