Write a menu drive program to print the following pattern
1 1 1 1 1
2 2 2 2
3 3 3
4 4
5
Answers
Answered by
13
To write a menu driven program there need to be two options. We have to print only one pattern, so we are not using menu driven.
import java.util.*;
public class Pattern
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int a,b,n;
for(a=5;a>=1;a--)
{
for(b=1;b>=a;b++)
{
System.out.println(b);
}
System.out.println();
}
}
}
Similar questions