In this program, the word INDIA will
displayed as
INDIA
INDI
IND
IN
I
class India
{
int i,j,len;
String s1="INDIA";
public void showPattern()throws Exception
{
len=s1.length();
for(i=0;i< len;i++)
{
for(j=0;j< len-i;j++)
{
System.out.print(s1.charAt(j));
}
System.out.println();
}
}
public static void main(String
args[])throws Exception
{
India ob=new India();
ob.showPattern();
}
No comments:
Post a Comment