1. ## Help.

I'm trying to create a triangle:
*
**
***
****
*****
But I can't make it.

Any help? Thanks.

2. What have you tried so far - you should know how it works by now: You post the code, we tell you how to move forward.

--
Mats

3. Use a for loop for to print each line. Inside the for loop add loop that runs to the current position in the outer loop printing a star each iteration. That would be one way of doing it.

4. Originally Posted by matsp
What have you tried so far - you should know how it works by now: You post the code, we tell you how to move forward.

--
Mats
I know how I could create a square, I've no idea how to create a triangle:
Code:
int i, j;
for(i = 0; i < 5; i++) {
for(j = 0; j < 5; j++) {
printf("*");
}
printf("\n");

5. How many stars do you need to print on each line? Think about that for a second.

6. Did you read my post?

7. Code:
int i, j;
for(i = 0; i < 5; i++) {
for(j = 0; j < 5; j++) {
printf("*");
}
printf("\n");
Think a bit, how the value of i going from 0 to 4 could help you determine how the maximum value of j, could go from 1 to 5 and you have your answer.

8. Originally Posted by mike_g
Yeah, I've read it and didn't actually understand ^^
MacGyver, I'm trying to think, but failing - How to increment one star at a time? :\
I could write 5 If's but that would be a waste - I'm trying to be efficient

Code:
int i,j;
for(i = 0; i < 6; i++)     {
for(j = 0; j < i; j++)
printf("*");
printf("\n");
}
Yay, thanks guys

9. A triangle is simply a set of 3 line segments that join up together, at the core definition anyway. One can be represented in other ways as well such as using a series of figures. Let's try a filled right triangle with the right angle at the bottom left corner, the easiest kind to make. Take a few coins or something and design something that looks like this. Hint: form the right angle first then do the hypotenuse. Look for any patterns then replicate this in a program. It should be very easy as it just involves variable manipulation and 2 characters being printed, one seen, the other a line feed.