 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print these two different patterns in C programming. Before starting, you can note my information. You can follow or subscribe my YouTube channel through the link youtube.com slash sanjaygupta underscore tech school. You can download my Android app that is TechMS which is available on Google Play. Now coming onto the topic, first I am going to demonstrate you how you can print this pattern. So we are going to analyze this. Here you can see I am placing high fun in place of space so that you can understand how much space is required before printing the letter. So if we write down the analysis in first row, total four number of spaces and one letter is required. Then in second row, three spaces and two letters in third row, two spaces, three letters, then one space, four letters, then zero space and five letters. This way we need two loops, one for printing spaces and one for printing letters. So spaces loop will be controlled by this n minus i and letters loop will be controlled by i. n is representing number of rows and i is representing the current row. So suppose initial value of i is one and n is five. So n will be five always and first time i will be one. So five minus one will be four. So four spaces will be printed. Second time i will be incremented by one. So to print second row, value of i will be two. So five minus two will be three. So this way, using this notation n minus i, we can find out these number of spaces for a particular row. Similarly, with the help of i, because i is representing a particular row, we can find out how many letters will be displayed in a particular row. So if i is one, so one letter, if i is two, then two letters, if i is three, then three letters and so on. So total three loops are required, one for printing space, one for printing letters and one for representing rows. Here you can see through printf scanf, I am reading number of rows. Then i loop is repeating n times. So i loop is responsible for providing row number through i variable. Then ch is initialized with a, then second loop. Here you can see the condition which I have demonstrated you earlier, n minus i. So n is total number of rows and i is representing current row. So first time current row is one. So value of i is one. So five minus one is four. This loop will repeat four times and it will print spaces. After printing four spaces, second loop, that is k is available, which is repeating i times and it will print letters through ch. And after printing a letter, ch is incremented by one, because in second row, just after a, we have to print b. So b will be printed by this ch plus plus. After completion of k, new line will be displayed using slash n. This way through this combination of nested loop pattern will be displayed on console. So I am executing this code. It is asking for number of rows. You can see the output and you can compare it with this output. Both are same. Now we have to display this reverse pattern. So for this purpose, you just have to change in first loop only. You have to initialize it with i equals to n. Its condition will be i greater than equals to one and it will be decreased by one every time. Now again, I am executing this code. You can see the output. It is printing the same pattern, which is required here. So friends, while i is starting from n, so suppose n is 5, then this j loop, which is printing zero space first time, because n is 5 and n is also 5. So 5 minus 5 is zero. That's why this loop will not repeat. But k loop will repeat 5 times because value of i is 5. So 5 letters will be displayed on console that are a, b, c, d, e. Then new line will be displayed. Then i will be decremented by one. So it will become 4. Then when control will be available on j loop. So n is 5 and i is 4. So one will be available here. So one space will be displayed with j loop. Here k loop will be repeating 4 times because i is 4 this time. So 4 letters will be displayed. So after one space, 4 letters will be displayed. And this way all the pattern in reverse order will be displayed on console. So I hope you have understood how we can print both the patterns with the help of nested loop in C programming. If you want to watch more programming related videos, you can follow my YouTube channel through the link youtube.com slash sanjay gupta underscore tech school. Thank you for watching this video.