A pattern like this to be displayed using Java program.
1
!
12
!
123
!
1234
!
class A
{
public void showPattern()
{
int i,j,x=0,c;
for(i=0;i< 7;i++)
{
c=1;
if(i%2!=0)
System.out.print(" !");
else
{
x++;
for(j=0;j< x;j++)
System.out.print(" "+c++);
}
System.out.println();
}
}
public static void main(String args[])throws Exception
{
A ob=new A();
ob.showPattern();
}
}
Related Post: BlueJ Programs On Pattern
No comments:
Post a Comment