Nested Loop
I am supposed to use a nested loop to create a 10x10 pattern of 9's. It's not filling in the middle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
using namespace std;
int main()
{
int repeat;
repeat = 10
int i = 1;
while( i <= repeat)
{
if( i == 1 || i == repeat) // first or last line
{
int j = 1;
while ( j <= repeat)
{
cout << "9";
j++;
}
}
else
{
cout << "9"; // display left outside asterisk
for(int j = 1; j <= repeat - 2; j++)
{
cout << " ";
}
cout << "9"; // display right outside asterisk
}
cout << endl;
i++;
}
repeat--;
system("pause");
}
|
Line 29?
LOL wow... thank you
Topic archived. No new replies allowed.