 Hello friends, I am Sanjay Gupta in this video I am going to demonstrate you how you can print this first triangle which is displaying 1 then 2 times 2 then 3 times 3 and so on and the reverse of this triangle 5 times 5 4 times 4 3 times 2 sorry 3 times 3 2 times 2 and 1 times 1 before starting you can note my information you can subscribe or follow my youtube channel that is sanjaygupta underscore tax school you can download my app based on programming which is tag MS available on Google Play now coming on to the topic you can see I have already implemented a code this code will display first pattern which is printing 1 2 2 3 3 3 and so on so here number of rows will be entered by the user and that value is stored inside n using scanf then first for loop is repeating from 1 to n second loop is repeating from 1 to i so suppose value of n is 5 first time i is 1 condition will be true because n is 5 then this j loop will repeat one time because j is 1 and i is also 1 so this loop will repeat one time only so i will be printing 1 on console after termination of j loop new line will be printed on console then i plus plus will be performed so new value of i is 2 then condition is also true 2 less than equals to n true then control will be transferred inside j loop again so this time j is starting from 1 and i is 2 so j loop will repeat 2 times and value of i is 2 so 2 will be printed twice on console after completion of j loop again new line will be displayed and this way first pattern will be displayed so first time executing this code you can see the output first triangle is printed on console now if you want to print it in reverse order so i must be start from n condition is i greater than equals to 1 and instead of i plus plus i am using i minus minus so by changing only i loop this reverse of the triangle will be printed on console so you can see suppose n is 5 so this time i is starting from 5 condition is true so this time j loop will begin from 1 and its condition will be 1 less than equals to 5 so this loop will repeat 5 times and i will be displayed 5 times on console and i value is 5 so 5 times 5 will be displayed on console after termination of j loop new line will be displayed then i minus minus will be performed so this time i is 4 again its condition will be checked 4 greater than equals to 1 which is true then j loop will begin from 1 now condition is j less than equals to 4 so this loop will repeat 4 times so 4 times 4 will will be displayed on console so now again i am executing this code i am entering 5 you can see the output 5 times 5 4 times 4 and so on the output is displayed on console so friends by changing in first loop you can print reverse of the triangle in this form 5 times 5 4 times 4 and so on so i hope you have understood how you can print both the patterns using nested loops NC programming if you want to watch more programming related videos you can subscribe or follow my youtube channel that is sanjay gupta underscore tech school thank you for watching this video