heres my code. i need a triangle that looks like:

****
_ ***
__**
___*

but mine looks like:

****
***
**
*

can anyone help ?

void drawTriangle(){                  //function to hold triangle code

  char c;                             //variable to hold character to make triangle
  int height;                         //variable to hold height of triangle

  cin >> height;
  cin >> c;
  cout<< "Triangle" <<endl;
  for (int i=1;i<=height;i++){
  for (int j=height;j>=1;j--){

      if (i<j){
        cout << c;
      }
      else{cout << " ";}
}
  cout << endl;
  }
}

So output the proper number of spaces before the *s

You can obviously output the *s, just do the opposite for spaces.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.