OutPut:
1
2 2
3 3 3
4 4 4 4
Source Code:
import java.util.*;
public class PyramidShape
{
public static void main(String args[])
{
int i,j,k,n=5;
for(i=1;i<n;i++)
{
for(j=1;j<n-i;j++)
{
System.out.print(" ");
}
for(k=0;k<i;k++)
{
System.out.print(i+" ");
}
System.out.println(" ");
}
}
}
1
2 2
3 3 3
4 4 4 4
Source Code:
import java.util.*;
public class PyramidShape
{
public static void main(String args[])
{
int i,j,k,n=5;
for(i=1;i<n;i++)
{
for(j=1;j<n-i;j++)
{
System.out.print(" ");
}
for(k=0;k<i;k++)
{
System.out.print(i+" ");
}
System.out.println(" ");
}
}
}
tanks working done
ReplyDelete