Write a menu driven program for the patterns given:
Pattern 1:
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8
3 4 5 6 7
4 5 6
5
4 5 6
3 4 5 6 7
2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
Answers
Answered by
2
Answer:
public class Main
{
public static void main(String[] args) {
int count=1, c=4,b=6;
for(int i=9;i>1;i--){
for( int j=count; j<=i;j++){
System.out.print(j);
}
count++;
System.out.println();
}
for(int i=c;i>=1;i--){
for(int j=i;j<=b;j++){
System.out.print(j);
}
c++;
b++;
System.out.println();
}
}
}
Similar questions
English,
3 months ago
Political Science,
3 months ago
Science,
7 months ago
Biology,
7 months ago
Political Science,
11 months ago