 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print these two patterns in C programming. Before starting, you can note my information. You can follow or subscribe my YouTube channel through this link that is youtube.com slash sanjaygupta underscore tech school. You can download my Android app that is Tech MS based on programming which is available on Google Play. Now coming on to the topic, first you have to understand how this pattern can be printed on console. So for this purpose, you can study this analysis. Here I have replaced space with hyphen and then digits are available. So if you want to print first row, then a loop will be required which will display spaces four times first and then one digit will be displayed. Now if we talk about second row, then three spaces so space loop will repeat three times now and digits loop will repeat two times now. So this way a loop will be required which will be printing spaces and then second loop will be required which will print required number of digits on console. Now to control these two loops, one more loop will be required which will represent which number of row we are printing. So for this purpose, I have already implemented this code for you. Here you can see I loop which will control row number second loop which will display spaces and third loop which will digit which will print digits. So now let's take an example. Suppose value of n is five which is received through this scanf because printf is printing enter how many rows you want to print. So n is five so this loop will start from one here condition is true. Now you can see second loop its condition is n minus i so n is five i is one. So this loop will repeat four times j loop is repeating four times so four spaces will be displayed after termination of j loop control will be transferred to k loop. So j loop is repeating four times but k loop will repeat one time because its condition is k less than equals to i and i is one. So one time it will print k so k is one so one will be displayed on console. So you can see our requirement if we talk about first row space loop will repeat four times and digit loop will repeat one time. So here you can see space loop is repeating four times and digits loop is repeating only one time. Then new line then i plus plus i will be two this time n minus i five minus two. So this time space loop will repeat three times and k loop will repeat two times because i is two. You can see in second row requirement is space loop should repeat three times and digit loop should repeat two times and that that is happening. So this way if i execute this code i will receive first pattern. You can see it here. I am receiving first pattern displayed on console. Now i want to print this pattern in reverse order. So for this purpose i have to change first loop that is representing i. So here initialization is i equals to n condition will be i greater than equals to one and in place of i plus plus i have used i minus minus. By changing only this first loop the reverse of the pattern will be displayed on console. You can see it here reverse is displayed as it is required in this pattern. Both are same. So with this way through this code i have printed reverse pattern. Now you can see i is starting from five. So first time j loop will repeat zero times because n is five and i is also five. So five minus five is zero. So no space will display on console and k loop will repeat five times because i is five. So it will display one two three four five which are values of k each time k loop will be repeating. So starting from one to five all the digits will be displayed in single row then new line then i minus minus so i will become four. So next time five minus four so one space will be displayed and k loop will repeat four times. So this way reverse of the pattern is displayed on console. So i hope you have understood how you can print both the patterns on console using nested loops in c programming. If you want to watch more programming related videos you can follow this link that is youtube.com slash sanjaygupta underscore tech school. Thank you for watching this video.