Saturday, November 1, 2014

Filled Under: , ,

Number Pattern 7 by while loop

Share

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

  1
  21
  321
  4321
  54321

*/

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

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

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


0 comments:

Post a Comment