CODE BOX
-----------------------------------------------------
/*program to print star pattern square box by while loop
1
12
123
1234
12345
*/
class npat9w
{
public static void main(String a[])
{
int n,i,j,k;
i=1;
n=Integer.parseInt(a[0]);
while(i<=n)
{j=n;
k=1;
while(j>i)
{
System.out.print(" ");
j--;
}
while(k<=i)
{
System.out.print(k);
k++;
}
System.out.print("\n");
i++;
}
}
}
-----------------------------------------------------
/*program to print star pattern square box by while loop
1
12
123
1234
12345
*/
class npat9w
{
public static void main(String a[])
{
int n,i,j,k;
i=1;
n=Integer.parseInt(a[0]);
while(i<=n)
{j=n;
k=1;
while(j>i)
{
System.out.print(" ");
j--;
}
while(k<=i)
{
System.out.print(k);
k++;
}
System.out.print("\n");
i++;
}
}
}
0 comments:
Post a Comment