public class halfinvertertri
{
public static void main (String[] args)
{
String str = "*";
String st = "*";
int row;
int col;
for(row=5;row>0;row--)
{
for(col=1;col<=row;col++)
{
System.out.print(" ");
}
System.out.print(str);
str = str + "*";
System.out.println ("");
}
}
}
OUTPUT WILL BE:
*
**
***
****
*****
try it yourself and try to make an experiment out of this example
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....
{
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....
Subscribe to:
Posts (Atom)