98
Write a program to print the following pattern
Algorithm
- STEP 1: START
- STEP 2: SET lines=8, i=1,j=1,k=1
- STEP 3: REPEAT STEP 4 to 13 UNTIL i is less than lines
- STEP 4: SET j=1
- STEP 5: REPEAT STEP 6 and 7 UNTIL j is less than or equals to (lines/2)
- STEP 6: 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 7: j = j + 1
- STEP 8: j = j – 2
- STEP 9: REPEAT STEP 10 and 11 UNTIL j is greater than 0
- STEP 10: 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 11: j = j – 1
- STEP 12: PRINT a new line
- STEP 13: i = i + 1
- STEP 14: EXIT
Solution:
C Program:
Output:
Java Program:
Output:
C# Program:
Output:
PHP Program:
Output:
Python Program:
Output:
Next TopicProgram to Print the Pattern 6