Java program to print the following patternAlgorithm:- STEP 1: START
- STEP 2: SET lines=8
- STEP 3: DEFINE i, j
- STEP 4: SET i=1.REPEAT STEP 5 to 14 UNTIL i
- STEP 5: SET j=1
- STEP 6: REPEAT STEP 7 and 8 UNTIL j <=(lines/2)
- STEP 7: IF j is equals to i PRINT j
ELSE IF i is greater than 4 and j equals (lines-i) PRINT j ELSE PRINT " " - STEP 8: j = j + 1
- STEP 9: j = j - 2
- STEP 10: REPEAT STEP 11 and 12 UNTIL j > 0
- STEP 11: IF j is equals to i PRINT j
ELSE IF i is greater than 4 and j equals (lines-i) then PRINT j ELSE PRINT " " - STEP 12: j = j - 1
- STEP 13: PRINT a new line
- STEP 14: i = i + 1
- STEP 15: END
Program:Output:
|