Thursday, October 30, 2014

Filled Under: ,

Number Pattern 9 by do While Loop

Share
CODE BOX 
--------------------------------------------------

/*program to print star pattern square box by do while loop

        1
       12
      123
     1234
    12345

*/

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

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

        do
        {

        System.out.print(k);
 k++;
        }
 while(k<=i);
System.out.print("\n");
i++;
}
while(i<=n);

}
}



0 comments:

Post a Comment