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 does %d do?
Which function in C can be used to append a string to another string?
How can I read/write structures from/to data files?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
Which is more efficient, a switch statement or an if else chain?
Is using exit() the same as using return?
write a program to find out prime number using sieve case?
What is the most efficient way to store flag values?
How can I sort a linked list?
What are the 5 elements of structure?
Is multithreading possible in c?
What is the purpose of void in c?
What is #include in c?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
Is linux written in c?