83
Q) Write a program to print the following pattern.
5432*
543*1
54*21
5*321
*4321
Algorithm
- STEP 1: START
- STEP 2: SET lines=5
SET i=1 - Step 3: REPEAT STEP 4 TO 8 UNTIL i is less than or equals to lines
- STEP 4: SET j=lines
- STEP 5: REPEAT STEP 6 and 7 UNTIL j is greater than 0
- STEP 6: IF j!=i
PRINT j
ELSE
PRINT * - STEP 7: j=j-1
- STEP 8: i=i+1
- Step 9: EXIT
Solution:
C Program:
Output:
5432* 543*1 54*21 5*321 *4321
Java Program:
Output:
5432* 543*1 54*21 5*321 *4321
C# Program:
Output:
5432* 543*1 54*21 5*321 *4321
PHP Program:
Output:
5432* 543*1 54*21 5*321 *4321
Python Program:
Output:
5432* 543*1 54*21 5*321 *4321
Next TopicProgram to Print the Pattern 3