I am trying to center the triangle, but I have no idea how.
I am trying to make a triangle like below:

*
    ***
   ****
  ******

(this is not the one I want, the format screws up)
I kind of forgot, do i use something like printf?

#include <iostream.h>
#include <conio.h>

main()
{
   int height;
   int i = 1;

	cout << "height?";
   cin >> height;

   while(i<=height)
   {
   	for(int j=0; j<i; j++)
      {
      	cout << "*";
      }
      cout << endl;
      i=i+2;
   }


   /*
   i = height - 2;
   while(i>=1)
   {
   	for(int j=0;j<i;j++)
      {
      	cout << "*";
      }
      cout << endl;
      i = i - 2;

   }       */
   getch();
}

So what's missing in your triangle?
What is necessary to get the *s in the right spot?

Are you trying something like this?

*
  ***
 *****
*******

Are you trying something like this?

*
  ***
 *****
*******

yes. But I dont't know how. Is there like a source code or anything for it?

commented: Did you bother to look at my post? -2

yes. But I dont't know how. Is there like a source code or anything for it?

  1. 4 lines
  2. Number of asterisks in the line is a formula based on the line number.
  3. Number of spaces before the first asterisk is a formula based on the line number.
for (int i = 0; i < someNumber; i++)
{
    // make a loop to print the spaces.
    // make a loop to print the asterisks.
    // display a newline.
}
commented: Short and exact +1

>Is there like a source code or anything for it?
Obviously there is a source code but you have to figure it out. Just follow the tips Vernon has given and you should do fine. If you are still uncomfortable, can you print this triangle?

*
**
***
****
*****

If you can, then your original problem is just a modification of this one. Just think about this...
If you can't, then pursue this one first.

I love being ignored.

I'll try 1 more time...

So what's missing in your triangle?
What is necessary to get the *s in the right spot?

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.