A Pattern

hi, how can i make an output like this?

*
**
***
****
*****

and its reverse ?


thanks in advance. :)
Last edited on
1
2
3
4
5
6
7
8
for (int row = 1; row <= 5; row ++) {
   for (int col = 1; col <= row; col ++)
      cout << "*";
   cout << "\n";
for (int row = 4; row >= 1; row --) {
   for (int col = 4; col >= row; col --)
      cout << "*";
   cout << "\n";
thanks but, can you use the loop " while " ? we haven't got that far, im a beginner , a freshmen. :)
To translate a for loop into a while loop:
1
2
3
4
for (a; b; c)
{
	d;
}

==>
1
2
3
4
5
6
a;
while (b)
{
	d;
	c;
}
oh, well that made sense. :) sorry i forgot , while and for are both loops. :) thanks. :)
Topic archived. No new replies allowed.