In this program the output will be like:
5 5 5 5 5
5 4 4 4 4
5 4 3 3 3
5 4 3 2 2
5 4 3 2 1
class Pat
{
int i,j,x;
public void show()
{
for(i=0;i< 5;i++)
{
x=5;
for(j=0;j< 5;j++)
{
System.out.print(x+ " ");
if(j< i)
x=x-1;
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
Pat ob=new Pat();
ob.show();
}
}
Related Post: BlueJ Programs On Pattern
No comments:
Post a Comment