Pascal’s triangle is a triangular array of the binomial coefficients. To build the pascal triangle, start with “1” at the top, then continue placing members below it in a triangular pattern. Each member is build using sum of above two numbers (except for the edge, which are all 1). To print triangle, the loop statement will be used many times, so nested Loop statements are used to construct triangular pattern.
For loops are used when we need to execute a statement fixed number of times. Nested “for loop” is used in a program to construct pyramid of digits and pascal triangle in C. If one for-loop is inside other for-loop then it is known as nested for-loop.
GET INSTANT HELP FROM EXPERTS!
- Looking for any kind of help on your academic work (essay, assignment, project)?
- Want us to review, proofread or tidy up your work?
- Want a helping hand so that you can focus on the more important tasks?
Hire us as project guide/assistant. Contact us for more information
Pyramid Triangle:
There are different ways to create pyramid.
- Star Pyramid
- String Pyramid
- Number Pyramid
4 for loops are used to construct above pyramid structure.
- One loop controls the number of lines i.e. the depth/height of the pyramid.
- One loop will print the spaces.
- One loop will print the numbers in ascending order.
- One loop will print the numbers in descending order.
Algorithm
1. Start.
2. Declare the variables
3. Accept the number of rows
4. Initialize outer counter to 1, for counting number of lines
5. Check the value of outer counter variable is less than the total number of rows. if yes, go to step 6 else go to step 15
6. Initialize inner counter variable to 1, to display the digits
7. Check if the value of inner counter variable is
StudyMumbai.com is an educational resource for students, parents, and teachers, with special focus on Mumbai. Our staff includes educators with several years of experience. Our mission is to simplify learning and to provide free education. Read more about us.
Leave a Reply
You must be logged in to post a comment.