public class PatternExample{ public static void main(String[] args){
int i,j,n=5;
for(i=0;i<=n;i++) { System.out.println(); for(j=1;j<=n-i;j++) System.out.print(j); for(j=0;j<2*i;j++) System.out.print(" "); for(j=n-i;j>0;j--) System.out.print(j); } } } OUTPUT IS
1234554321 1234 4321 123 321 12 21 1 1
PLZ DESCRIBE ME THAT HOW TO MAKE THIS PROGRAM AND WHATS THE WORKING OF EVERY LOOP
The above code consists of four loops. The first loops create the five rows. The second loop first increment the value of j by decrement the value of n. The third loop provides the incremented space. The fourth loop first decrement the value of j.
Ads