Help c++

Write a program that displays n depth * pyramid.

For example,Input: 4

This is what i have so far but it not giving me what i want.

#include <iostream>
using namespace std;

int main()
int star;
int count=1;
cout<<"Enter the number: ";
int length=(2*star)-1;
for(int i=1;i<=4;i++){
for(int j=1; j<=length; j++){

for(int l=1; l<=count; l++){
count +=2;

Think about the question. So starting at zero, you need to print (2x + 1) stars (where 0 <= x <= length) for each row. So using this equation and writing down number of stars for each level and try using a simple nested-for loop to solve this.

Remember that since I started at 0, if you decide to start at one, the equation is now (2x - 1) for each row
Last edited on
Topic archived. No new replies allowed.