 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 app tag image that is available on google play. Now coming onto the topic, first you have to understand how this pattern will be printed. So here some spaces are available and then asterisk is printed. So here we have to implement three loops. First will be counting which row you are displaying. Then you have to print spaces through second loop and then asterisk with third loop. So you can understand it by this diagram. Here hyphen is representing spaces and then you have to print asterisk. So you can see here four spaces and one asterisk. Then three spaces and two asterisk, two spaces, three asterisk, one spaces, four asterisk, zero spaces and five asterisk. So for this purpose you have to use two loops. One for space and one for asterisk. So now you can see this code. Here number of rows I have received through printf scanf. Then I have implemented first loop which is repeating n times. That means it is repeating till number of rows that is n. So starting from one till n it will repeat. Then this second loop is responsible for printing spaces. So first time we require four spaces. So you can see suppose n is five. So I will be one first time. So n minus i, five minus one. Four will be available here. So this loop will repeat four times. So four spaces will be displayed. Then control will be transferred to this K loop. This K loop is starting from one and it is repeating i times. So i is right now one. So this loop will repeat one time. So it will print asterisk. So our requirement was four spaces and one asterisk. So it is fulfilled. Now second time i plus plus is available. So i will become two. Now check this condition n minus i. n is five. i is two. So it will become three. So this time this loop will print three spaces and K loop will repeat two times because i is two. So two asterisk will be printed. So three and two. You can see here three spaces and two asterisk. So this way with the help of these loops you will be able to print first pattern. I am executing this code. You can see the output. The required pattern is printed here. You can compare both the patterns. Now we have to print this pattern in reverse order. First five asterisk then one space four asterisk two space three asterisk three spaces two asterisk and four spaces one asterisk. So here we just have to change in first loop. I am starting it with n. Its condition is i greater than equals to one and i minus minus. So now you can see suppose n is five. So five minus five. This loop will repeat zero times and this loop will repeat five times. So zero space and five asterisk. You can see zero space and five asterisk. Then second time i minus minus. So i will become four. Here five minus four. So this loop will repeat one time. So one space and this loop K loop will repeat four times. So one space and four asterisk. You can see here one space and four asterisk is required. So with this change the reverse of the pattern will be displayed on console. You can see it here five four three two one spaces along with the required spaces are displayed here. So I hope you have understood how we can print both the patterns with the help of 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.