Question 13 : Write a program in Java to print the following pattern :
public class pattern_1
{
public static void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
System.out.print(i);
}
System.out.print("\n");
}
}
}
Output :
1
22
333
4444
55555
Java Program :
public class pattern_1
{
public static void main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=i;j>=1;j--)
{
System.out.print(i);
}
System.out.print("\n");
}
}
}
Output :
1
22
333
4444
55555
Note : Use the calculator and the notepad provided, at the top, to dry run the program.