Saturday, November 1, 2014

Filled Under: , , ,

Number Pattern 2 by while loop

Share

Code Box by while loop
-----------------------------
/*program to print number pattern box by while loop

  1
  12
  123
  1234
  12345

*/

class npat2w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=1;
        while(j<=i)
        {
        System.out.print(j);
        j++;
 }

System.out.print("\n");
i++;
}
}
}

0 comments:

Post a Comment