Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How make a program that custom-draws a pyramid

anundalanundal oregonMember Posts: 0

Write your question here.
Okay, so I am trying to figure out how to create a program that will draw a triangle using *'s with a base the has a user-inputted number of *'s like so


In reality, its the top of a tree, I also need to create custom-sized trunk using loops, but how would I go about centering it, or getting it more centered under the tree top, like this



right now I am simply trying to properly code it so that it will produce the correct number of *'s per line, like so:

After that I will worry about the whitespaces (it doesn't necessarily have to have 5 *'s on the bottom, it has whatever number the user inputs.

int width = 0;
int height = 0;
int i = 0;
int leafWidth = 0;
int i2 = 1;
int i3 = 1;
int i4 = 1;

cout << "Enter trunk height: " << endl;
cin >> height;
cout << "Enter trunk width: " << endl;
cin >> width;
cout << "Enter leaves width: " << endl;
cin >> leafWidth;
cout << endl;
while (i2<=leafWidth){
    while (i3 <=i4){
        cout << "*";
    cout << endl;

    i2 = i2+2;
Sign In or Register to comment.