pyramid of asterisk


could someone help me to output the following pyramid:
*
* *
* * *
* * * *
to n of times (using FOR loop)

thanks in advance
That looks an awful lot like a homework question. Do you have any code already written? I can probably help you find where you're making your mistake.
thanx dirtrider for your efforts .i appreciate it.
Hi

Try this one

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

void displayRow(int n)
{
for (int i = 1; i <= n; i++)
cout << '*';
cout << endl;
}
int main()
{
int m;

cout << "Enter a positive integer: ";
cin >> m;

for (int j=1; j <= m; j++)
displayRow(j);
return 0;
}
Topic archived. No new replies allowed.