Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Pascal's Triangle

Pascal's Triangle

Pascal's Triangle


some time ago I started to learn Turbo Pascal.
Now I've got a complex question, for me that is.

I want to write a program that prints out Pascal's Triangle.
But I'm stuck since I started to figure out how to write this program.

The program has to ask the user how many rows it has to display, after that the program should give Pascal's Triangle up to the number of rows the user has determined.

I hope someone can help me with this problem.
I'm too stuck ;)

Thanks for helping me!

Pepijn de Brouwer

RE: Pascal's Triangle

ok, and where are you stuck? Let's see what you have so far, and then we can fill in :)



RE: Pascal's Triangle

As I told you, I got stuck from the start.
This is what I've got so far...

PROGRAM Pascalstriangle;
VAR counter,ammount:INTEGER;


   WRITE('Give number of rows: ');
   FOR counter:=1 TO ammount DO
   WRITE('Press ENTER to stop');

I hope you can help me out, because I don't know what to do next.

Thanks in advance!

Pepijn de Brouwer

RE: Pascal's Triangle

Alright, not too much to start... :) I'm assuming you know how to determine the values of Pascal's triangle? Look at each row as an array of numbers. If all you want to do is print the result, then all you need to retain in memory is the current line and the previous line.

I'm sorry, I'm heading out for work, so I can't write the whole thing for you... I'll stop by tonight and see if anyone helped you, and if not, I'll be glad to assist. In the meantime, see if you can determine how to calculate the current row, based on the previous rows...

Things you know:

1st row has only one value of 1.

next rows always have one more value than the previous row.
(think of giving your program a limit in the number of row... you wouldn't want someone to enter 1 billion as a requested number of rows)

and instead of picturing your triangle as a triangle, look at it as a block... it will make it easier to figure out the calculations...


Shouldn't be too difficult :)



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close