cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : pyramid of asterisk
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

question  pyramid of asterisk

joe25 (6)

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

thanks in advance
|
jlamothe (14)
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.
|
Dirtrider (15)
http://www.cplusplus.com/src/triangle.zip
|
joe25 (6)
thanx dirtrider for your efforts .i appreciate it.
|
velaphi (30)
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;
}
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us