• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Study Abroad
  • Writing Services
  • About Us
  • Contact
  • Blog

AcademicsHQ

Instant access to Study Resources, 24/7 Homework Help, Tutors, to help you ace your homework.

homework help
  • Academic Writing
    • Dissertation Writing
    • Report Writing
  • Research Process
  • Referencing Guide
  • Resume Writing
Home » Blog » Write a program to display pyramid and Pascal triangle

Write a program to display pyramid and Pascal triangle

June 24, 2019 by academicshq Leave a Comment

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 <= outer counter variable. If yes, go to step 8 else go to step 14 8. Check if the value of inner counter variable is equal to 1. If yes, go to step 9 else go to step 11 9. Assign the value of inner counter variable to another variable, say x 10. Display value of x. 11. Calculate value of x as (x*outer counter-inner counter+1)/ (outer counter - 1) 12. Display value of x 13. Increment inner counter variable and goto step 7 14. Increment outer counter variable and goto step 5 15. Stop

Filed Under: Computers

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


Primary Sidebar

Recent Posts

  • Hindi Project Work: Hindi Pariyojana Karya (हिंदी परियोजना कार्य)
  • Geography Projects Class 10
  • Money Education for Kids: Teach Them Financial Responsibility
  • Bachelor of Management Studies (BMS): Project Work
  • BMS (Bachelor of Management Studies): Assignment & Project Topics

Categories

  • Black Book Projects
  • Book Reviews
  • Business Law
  • CBSE Study Notes
  • Computers
  • Digital Business
  • Economics
  • Education Articles
  • English Literature
  • Environmental
  • Essays
  • Foreign Education
  • General
  • Geography
  • German
  • Global Education
  • Hindi
  • History
  • Hotel Management
  • HRM
  • Jobs
  • Management
  • Management Notes
  • Math
  • Media Study Notes
  • Movie Reviews
  • Primary
  • Research
  • Sample Essays
  • School Projects
  • School Study Notes
  • Science
  • Self Improvement
  • Services
  • Social Studies
  • Sociology
  • Solved Assignments
  • Student Software
  • Uncategorized
  • Writing Tips

Footer

CLASS NOTES

  • Class 10 . Class 9
  • Class 8 . Class 7
  • Class 6 . Class 5
  • Class 4 . Class 2
  • Class 2 . Class 1

ACADEMIC HELP

  • Essay Writing
  • Assignment Writing
  • Dissertation Writing
  • Thesis Writing
  • Capstone Projects
  • Homework Help
  • Report Writing

SERVICES

  • Writing Services
  • Book Review
  • Ghost Writing
  • Make Resume/CV

ABOUT US

  • About Us
  • Contact
  • Privacy Policy
  • Blog

Copyright © 2025 · News Pro on Genesis Framework · WordPress · Log in