Number Left Half Pyramid Pattern Using C program
C Program:
Output 1:
Output 2:
From the above program,
ü num is used to store the number of rows to be printed given by the user.
| i | i<=num | j | j<=i | Print j | j++ | Print new
  line | i++ | 
| 1 | 1<=3 | 1 | 1<=1 | 1 | 2 | Still in j
  loop | |
|  | 2 | 2<=1 false | Doesn’t
  execute | Yes | 2 | ||
| 2 | 2<=3 | 1 | 1<=2 | 1 1 | 2 | Still in j
  loop | |
|  | 2 | 2<=2 | 1 12 | 3 | |||
| 3 | 3<=2 false | Doesn’t
  execute | yes | 3 | |||
| 3 | 3<=3 | 1 | 1<=3 | 1 12 1 | 2 |   Still in j loop | |
|  | 2 | 2<=3 | 1 12 12 | 3 | |||
| 3 | 3<=3 | 1 12 123 | 4 | ||||
| 4 | 4<=3 False(goes
  out of the j loop) | Doesn’t
  execute | yes | 4 | |||
| 4 | 4<=3 false | Doesn’t execute | |||||
ü i is the outer loop and j is the inner loop.
ü whenever j loop starts it's value will be assigned to 1.
ü j loop continues till the condition j<=i fails then only it moves to the outer loop i.
ü when j loop fails, new line will be printed then it moves to i loop.
ü when condition i<=num fails in i loop then the execution stops.
Note: If you are using mobile then view in desktop site to get the better view of the table.
0 Comments