## Pascal's Triangle

## Pascal's Triangle

(OP)

Hello,

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

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

Cheers,

Realm174

## RE: Pascal's Triangle

This is what I've got so far...

PROGRAM Pascalstriangle;

VAR counter,ammount:INTEGER;

PROCEDURE GiveRow(i:INTEGER);

BEGIN

WRITELN('Row',i);

END;

BEGIN

WRITE('Give number of rows: ');

READLN(ammount);

FOR counter:=1 TO ammount DO

GiveRow(counter);

WRITE('Press ENTER to stop');

READLN;

END.

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

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...

___

|_1_|___

|_1_|_1_|___

|_1_|_2_|_1_|___

|_1_|_3_|_3_|_1_|___

|_1_|_4_|_6_|_4_|_1_|

Shouldn't be too difficult :)

Cheers,

Realm174