 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print these two patterns. One is printing stars in 1, 2, 3, 4, 5 form and another is printing stars in its reverse order. Before starting, you can note my information. You can follow or subscribe my YouTube channel that is sanjaygupta underscore tech school. You can download my Android app based on programming which is available on Google Play. The name of app is tech image. Now coming on to the topic, first I have included a header file stdio then main function is defined here three variable i, j, n are declared. Then with the help of printf, this message enter how many rows you want to print will be displayed on console scanf will read the number in n variable. Then I have implemented for loop which is starting from one and it will terminate while this condition will be false i less than equals to n. So in short, this loop will repeat n times inside i loop. Another for loop is implemented which is starting from one and condition is j less than equals to i. So in short, this loop will repeat i times. So first value of i will be one. So j loop will repeat one times. Then i will become two. So j loop will repeat two times. So with this nested loop formation, this first pattern will be displayed on console. So I'm executing this code. You can see one, two, three, four, five. These stars are displayed on console. Now we have to print these stars in reverse order. So you just have to change first for loop that is controlled by i. So I am initializing it by n. Its condition is greater than equals to one and instead of i plus plus, I am using i minus minus. So suppose value of n is five. So I will be initialized by five. Then condition will be checked, which is true. Then control will be transferred to j. So j is starting from one and condition is j less than equals to i. So right now value of i is five. So this j loop will repeat five times and five stars will be displayed on console. After completion of J loop, new line will be displayed on console. Then i minus minus will be performed. So i is now four. So next time J loop will repeat four times. So this way pattern of this star triangle will be printed in reverse order. So it is also known as water image of this triangle. So this pattern is water image of this first triangle. So now I am executing this code. I am entering five. You can see pattern is printed in reverse order five, four, three, two and one stars. So by changing only i loop, we can print reverse of the triangle. So I have demonstrated how you can print both the patterns using nested for loop. I hope you have understood the concept well. If you want to watch more programming related videos, you can follow or subscribe my YouTube channel that is Sanjay Gupta underscore tech school. Thank you for watching this video.