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 does %d do?

705


Which function in C can be used to append a string to another string?

637


How can I read/write structures from/to data files?

539


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

760


Which is more efficient, a switch statement or an if else chain?

567






Is using exit() the same as using return?

666


write a program to find out prime number using sieve case?

1626


What is the most efficient way to store flag values?

676


How can I sort a linked list?

626


What are the 5 elements of structure?

553


Is multithreading possible in c?

557


What is the purpose of void in c?

609


What is #include in c?

587


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

1402


Is linux written in c?

590