Sunday, September 22, 2013

Filled Under: , , , , ,

Number Pattern 9 by For Lop

Share


Code Box by for loop
--------------------------

/*program to print star pattern square box by for loop

        1
       12
      123
     1234
    12345

*/

class npat9
{
public static void main(String a[])
{
int n,i,j,k;

n=Integer.parseInt(a[0]);

for(i=1;i<=n;i++)
{
        for(j=n;j>i;j--)
        {
        System.out.print(" ");
        }

        for(k=1;k<=i;k++)
        {

        System.out.print(k);
        }
System.out.print("\n");

}
}

}

0 comments:

Post a Comment