Friday, January 8, 2016

Pattern On Numeric And Letter


Print the pattern as follows:

1a
1a 2b
1a 2b 3c
1a 2b 3c 4d

Download eBook on BlueJ 


class Happy
{
int i,j;
char k;


 void show()
 {
  for(i=1;i< 5;i++)
{
 k='a';
for(j=1;j<=i;j++)
{
 System.out.print(j+""+k+" ");
 k=(char)(k+1);
}
System.out.println();
}
}
 public static void main(String args[])
{
 Happy ob=new Happy();
ob.show();
 }
}

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner