Write a program in c to print the following pattern

And we need to approach it the same way we did the pattern number 2. It has a square base which tapers off to a single point giving it the height or the third dimension.

Pattern programs in c pdf

Now what are these triangles? It surely looks different because there are spaces before stars but other than that its same as the previous pattern. Now it may sound very confusing but lets see some pseudo code. In the second line there is 1 star. If you look carefully the number of lines getting printed are correct. Hence, the numerous ways to print the same in C programming are as follows: Using For Loop Read the row number which represents the height of the pyramid and stores that value into the variable n. No of triangles 3. Hopefully you enjoyed reading this tutorial. Only 1 star per line is missing. Quite a few mausoleums, temples, tombs etc. Since, row and column count is same, both loops will run for size amount of time. If you have any doubts please use the comments. Anyway you can always give it a try.

Make sure you try to draw it first and check it with my one. And we do both of them separately. At 1st row 2nd for loop prints spaces,3rd for loop prints stars, cursor comes to next line.

c program to print patterns of numbers and alphabets

So the height of the pyramid is 5. Ask the user to enter the size.

c program to print patterns of numbers and alphabets

You see you can use both for loops and while loops but she always preferred for loops.

Rated 5/10 based on 3 review
C Pyramid Star Pattern Program