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
What is #ifdef ? What is its application?
What is the use of extern in c?
What are different types of operators?
In a switch statement, explain what will happen if a break statement is omitted?
How many levels of indirection in pointers can you have in a single declaration?
How do I round numbers?
What are the different types of data structures in c?
Difference between Shallow copy and Deep copy?
What is a pointer in c?
What is use of null pointer in c?
Write a program to know whether the input number is an armstrong number.
What is union in c?
What is the difference between text and binary modes?
How many levels of pointers can you have?
What tq means in chat?