Can you please help me do a asterisks of pyramid using the drawbar function, im new to c++ please help. Thank you in advance
this is the drawbar function:

the output should look like:
  *
 ***
*****

*******

  /*Overloaded drawbar() program.*/
#include<iostream.h>
void DrawBar(int Length)
/*Diplays a bar of asterisks of length Length.
  Length assumed>=0 */

  const char Mark= '*';
  for (int i=0; i<Length; i++)
  cout<<Mark;
  cout<<endl;
  }
  void DrawBar(int Length, char Mark)
  /*Diplays a bar of length Length using character Mark.
  Length assumed>=0 */
  { 
    for (int i=0; i<Length; i++)
    cout<<Mark;
    cout<<endl;
   }
   int main()
    {
    DrawBar();
    DrawBar();
    DrawBar();
    DrawBar();
    return();
    }

Your asteriks are uneven.
You could center a number of asteriks in a string of blanks(if the chars are equiditant, but I guess that is the case here) and cout the string.

Comments
how do i do that? sorry im new in c++

include <iostream>

using namespace std;

//Modify your way

//main

int i , j , lp , ishave ;

lp = ishave = 3; // <-- change number 1 , 2 , 3 , 4 , 5 , 6 ... more ^^

bool PutCheck = false;

int putcount = 1;

for( i=0; i<lp; i++ ){

    for( j=0; j<( lp*2 - 1 ); j++ ){

        if( ( ishave - 1 ) > j || ( ishave - 2 + putcount ) < j ){
            PutCheck = false;
        }else{
            PutCheck = true;
        }

        cout << ( PutCheck == true ? "*" : " " ) ;
    }

    ishave--;

    putcount+=2;

    cout << endl;

}
Attachments 33344.png 1.16 KB 3334444.png 1.37 KB 333.jpg 3.28 KB
This question has already been answered. Start a new discussion instead.