 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print these two patterns using 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 Techimus, which is available on Google Play. Now to print this first pattern, we have to analyze it like this. Here I have replaced all the spaces with hyphen and then letters are available. So I have counted in first row four spaces and one letter is required in second row three and two in third row two and three in fourth row one and four and in fifth row zero and five spaces and letters are required. So here two loops will be requiring one for printing spaces and one for printing letters. So here you can see if number of lines are five. So if we subtract five minus one, so four will be available then five minus two three will be available five minus three two five minus four one five minus five zero. So for printing space, if I replace five with n, n is number of rows and I am subtracting it with I here I will be representing third loop, which will provide row number. So if I is one, then five minus one is four if I is two five minus two is three. So this way this n minus one is the condition of this space loop. And for printing letter condition will be I if we are on first row, then one letter, if we are on second row, then two letters, if we are on third row, then three letters. So for printing letters, the loop will be required and its condition will be I. Now I'm moving to the code. Here you can see first loop is representing number of rows. So I will be providing row number based on that second loop is implemented. Here you can see the condition which I have explained you n minus I. So this condition is here for controlling J loop. J is starting from one. Suppose n is five, five is number of rows which is received through this printf scanner and I is first time one. So five minus one is four. So this loop will repeat four times. So four spaces will be displayed. Then another loop which is controlled through I. So it is starting from one and it will repeat till I. Here first time value of I is one. So it will repeat one time only and it will display CH value of CH variable. You can see CH is declared above as a and its data type is character. After completion of this loop, CH will be increased by one. So it will become B and new line will be displayed. Then I plus plus I will become two. So five minus two this time J loop will repeat three times and K loop will repeat two times and B will be displayed twice. Now I am executing this code. I am entering five. You can see the output. It is matching with the first pattern. Now we have to print it in reverse order. So to print it in reverse order, this space and letters loop will remain same. We just have to change the first loop that is controlling rows. I am initializing it with N. Its condition is I greater than equals to one and I minus minus. So I have changed in first loop only. Rest of the loops are same. So first time executing this code. Then I will explain this. You can see the output. Sorry. Here it is printing A instead of E. So now if you want to print E here, you have to place E here and then CH minus minus. So now again I am executing this code. I am entering five. Now you can see the required pattern is printed. So if you want A five times in first row, then you can start CH with A and you can increase it by one. And if you want to start it from E, then you can initialize it with E and then you can decrease it by one. So this way both the patterns are displayed on console. Now I am explaining this concept here. Suppose value of N is five. So I will be initialized by five. Then J will repeat zero times because N is five and I is five. So five minus five is zero. It will not execute and K loop will repeat five times because I is five. So five times value of CH will be displayed. Then CH will be decremented by one. New line will be displayed. Then I will be decreased by one. So it will become four. Next time five minus four. So J loop will repeat one time only. So one space will be displayed. Then the scale will repeat four times. So four letters will be displayed with the help of this K loop. So you can see here in first row zero space in second row only one space is required. Then in third row two spaces are required. So this way both the loops J and K will be repeated and both are controlled through I. So I have changed only in I loop so that reverse of the pattern will be displayed on console. I hope you have understood how I have displayed both the patterns with the help of C program. If you want to watch more programming related videos, you can follow my YouTube link that is youtube.com slash sanjay gupta underscore tech school. Thank you for watching this video.