Thursday, October 30, 2014

Filled Under: ,

Number Pattern 10 by do while loop

Share

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

        1
       21
      321
     4321
    54321

*/

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

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

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

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

}
}
















0 comments:

Post a Comment