write a program to display the numbers in the following
format
4 4
3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2
3 3 3
4

Answer Posted / padmapriya

class Pattern{
public static void main(String[]args){
for(int i=4;i>0;i--){
for(int j=0;j<5-i;j++){
System.out.print(i);

}
for(int j=0;j<i;j++){
System.out.print(" ");
}
for(int j=0;j<i-1;j++){
System.out.print(" ");
}
for(int j=0;j<5-i;j++){
System.out.print(i);
}
System.out.println();
}

for(int i=0;i<5;i++){
for(int j=0;j<i;j++){
System.out.print(" ");
}
for(int j=0;j<9-2*i;j++){
System.out.print(i);
}
System.out.println();
}
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is #ifdef ? What is its application?

633


What is the use of extern in c?

633


What are different types of operators?

583


In a switch statement, explain what will happen if a break statement is omitted?

615


How many levels of indirection in pointers can you have in a single declaration?

581






How do I round numbers?

585


What are the different types of data structures in c?

584


Difference between Shallow copy and Deep copy?

1558


What is a pointer in c?

671


What is use of null pointer in c?

557


Write a program to know whether the input number is an armstrong number.

658


What is union in c?

622


What is the difference between text and binary modes?

630


How many levels of pointers can you have?

689


What tq means in chat?

569