Pascal's Triangle Help

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
xkse

Pascal's Triangle Help

Post by xkse »

I'm currently trying to program Pascal's triangle and have no clue how to go about doing it

Iknow what the triangle does, how it is formed, and most things about it but have no clue how to convert it into a program to do it for me

I know people don't just like to give out programs to random newbs like me, but any help would be greatly appreciated (even if its just the beginning of the code)


Thanks
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Pascal's Triangle

Post by Zim »

The fun in programming is learning to do it and seeing positive results.

Start with an array and a loop. Make the array as big as you need it to be for the final row of the triangle.

Start with a two element array consisting of 1, 1.

Within the loop reproduce the first array element, then compute (and print) element 1+2, 2+3, 3+4 etc. until you come to the end of the row for that pass thru the loop. You'll have to test for this or be real clever with minding your loop index. The last element of the row will be the last element of the last row + zero, which will just reproduce the last element again, "1".

Be sure to test or loop carefully so you don't go beyond the limit of your array dimension.

If you don't know how to work with arrays or loops, better check out a tutorial first!

Good luck, and happy computing!
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
xkse

Post by xkse »

Thx, I'll try that
Post Reply