Monday, October 4, 2010

making half triangle with java using forloop

public class halftri
{
public static void main (String[] args)
{
for(int row=1;row<7;row++)
{
for(int col=1;col<=row;col++)
{
System.out.print("*");
}
System.out.println ("");

}
}
}

output will be:


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

try it yourself and make some experiment out of this example....

No comments:

Post a Comment