Hey, guys im stuck on this problem. I'm supposed to make a base pyramid in the format:
--------*
------***
----*****
Basically, it takes user input and subtracts two on the next line. (e.g. 5, 3, 1)
Right now I can only make it go down one by one, I know it's an extremely basic logic problem but im stressing out on this one thing. Do I add an extra for loop or it it some current value to change?
Here is my code:
#include <iostream>
using namespace std;
void main()
{
int base;
cout << "Please enter the base of the pyramid";
cin >> base;
for(int i=0; i<= base-1;i++)
{
for(int k=0; k<=base-i;k++)
cout <<" ";
for(int j=1; j<=i+1;j++)
{
cout <<"* ";
}
cout <<"\n";
}
}
I would really appreciate a hint or step in the right direction. Thanks!