 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can print this pattern 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 Techimus which is available on Google Play. Now coming on to the topic, here you have to print this pattern. You can see some space is available and then asterisk or star is printed. So here I am modifying this pattern by typing this here in place of space. I am typing hyphen and then asterisk or star so that you can identify how many spaces and how many stars are required. So spaces and asterisk or you can say star. In first row, four spaces and one star is required. In second row, three spaces and three stars. In third row, two spaces and five stars. In fourth row, one space, seven stars. Then in last row, zero space and nine stars. So now you can identify the pattern. Spaces four three two one zero. So one loop is required to print spaces. We can print this by this n minus i. So here n is representing number of rows. Suppose number of rows is five and i is representing which number of row you are printing. So i indicates current row and n represents number of rows, total number of rows. So suppose total number of rows are five. So n will be five always and i is representing current row. So current row first current row is first. So I will be one. So five minus one means four. So four spaces will be displayed second time when row value is two. So it will be five minus two. So it will provide three. Then five minus three. It will provide two five minus four one five minus five zero. So with this n minus i, we can control the loop which will be printing spaces. Now for printing asterisk, you can see in first row one, then three, then five, then seven and then nine. So all digits are required in each row. Now I am going to display. Sorry. Now I am going to implement the code for you so that you can print this pattern. So here some variables are declared. Then printf is printing this message. Then scanner will read number of rows. Here I am implementing first loop starting from one. It will repeat n times. So this loop is for identification of row number. Then for printing space, I am starting another loop which will repeat n minus i times and this loop will print spaces. You can see I have controlled this loop with this condition j less than equals to n minus i. So suppose value of n is five and will start from one. So first time five minus one, which will be four. So four spaces will be displayed in first row when value of five will become two. So this condition will be five minus two. That is three. So second time it will print three spaces. So this way required spaces will be displayed now to print asterisk or star. Another loop is required, which is starting from one. Now here condition will be i into two minus one. And inside this I am printing asterisk. So it will print asterisk or star. Now you have to notice this condition i into two minus one. So I is representing one, two, three, four, five. So first time it will provide one. Second time it will provide two, then three, then four, and then five. So each time I will be providing row number. So when row number will be one, it will be multiplied by two. And then it will be decremented by one. So this notation is that I am multiplying natural number by two and I am decrementing its result by one. So it will provide odd number. So one into two minus one equals to one when row number will be two. So I value of five will be two. So two into two minus one is three, then three into two, six minus one is five. So if we multiply natural numbers by two and we subtract it by one, we receive odd numbers that are one, three, five, seven, nine. So with this condition asterisk will be printed in odd numbers. Then after completion of this loop using slash n new line will be displayed. So this is the complete code which will display required pattern on console. I'm entering number of rows as five. You can see the output. The required pattern is printed on console. So I hope you have understood how this pattern is printed with the help of these three loops. First one is controlling rows. Second is printing spaces and third is printing asterisk or star. I hope you have understood the concept. Well, if you want to watch more programming related videos, you can follow my YouTube channel through youtube.com slash Sanjay got underscore textbook link. Thank you for watching this video.