heya anyone can help me with the pascal triangle program in c++??

## All 5 Replies

What issues are you having in your code?

i can't understand the logic...as in what should i input
and i'm still new to programming so having many issues

What difficulty is there to understand in:
`Each number in the triangle is the two numbers above it added together (except for the edges, which are all "1").`
I assume you can add to numbers, don't you?
If you still find that difficult please tell us.

You need to work out how you would explain doing it to someone who had no idea what you were talking about. For example:

You're going to output lines of numbers
The first line will be just the number 1.
The second line will have two numbers in it.
The third line will have three numbers in it.
The fourth line will have four numbers in it.
And so on.

On each line apart from the first line, the FIRST number you write out will be the same as the FIRST number on the previous line.
On each line apart from the first line, the LAST number you write out will be the same as the LAST number on the previous line.
On each line apart from the first line, all other number will be the sum of the previous line's corresponding number and the number before that (i.e. for any line, the second number will be the sum of the previous line's first and second number; for any line, the third number will be the sum of the previous line's second and third number, and so on).

This is programming. Thinking about the problem in a way that the solution lends itself to a programmatic solution. Examining the problem and breaking it down into simple, small steps. This is programming. All the rest is learning tools and syntax.

commented: Well said. +15
commented: good +14

@OP, have you used flow charts before. This is a great way to introduce programming concepts?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.