star pyramid

hey guys!

just working on a program to make a star pyramid.

so far this is what i have:

#include <iostream>
using namespace std;

int main()
{

int number, stars = 0, rowend = 0;
cout << "Enter a number: " << endl;
cin >> number;

for(int row = 1; row <= number; row++)
{
cout << endl;

for(int col = 1; col <= row; col++)
{
for(int rowsp = number; rowsp >= 0; --rowsp)
{
cout << " ";
}
cout << "*";

for(int line = 1; line <= stars; line++)
{
cout << endl;
stars += stars +1;
}
}

}

cout << endl;

return 0;
}

input: 5

output:

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

what i need is:
this should look like a pyramid of stars but....yeah.

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

what am i doing wrong?

tbg24
Last edited on
Topic archived. No new replies allowed.