I want to draw a triangle with stars like below using for loop, but i really don't have any idea of how to do this ? Triangle is going to be like this:
*
**
***
****
*****
******
*******
********
*********
**********
and so on. Can anybody please help me ?
public class Project1 {
public static void main (String[] args){
int c, d, e;
for (c = 1 ; c <= 8 ; c++){
for (d = 1 ; d <= c ; d++){
System.out.print ("*");
}
System.out.println("");
}
for (e = 1 ; e <= 4 ; e++){
System.out.println ("***");
}
}
}
This is what i have found from the internet, but i did not understand the reason why it uses two loops. ( i understood the one used to construct the stem. )