Question

use scheme program

The following pattern of numbers is called Pascal's triangle.
colo col 1 row 0 1 1 col 2 row 1 | 1 row 2 1 2 row 3 (1331) col 3 col 4

The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it.

(pascals 0 0) → 1
(pascals 2 0) → 1
(pascals 2 1) → 2
(pascals 4 2) → 6
(printTriangle 5)

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
  1. [5 marks] Write a procedure that computes elements of Pascal's triangle given row and column indices. Any invalid indices should return a value of 0.
    For example,
  2. [7 marks] Using your solution to the previous part, write a procedure (printTriangle n) that prints n rows of Pascal's triangle to the screen.
    For example,
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please refer to solution in attached images(2 images)

Solution is provided in Cpp(please read comment for better understanding)

For Part A.

Let us name the function as Pascal Note - We need 2 for loops to move thowugh each how & column, under conditions 1 column i

For Part B.

This function will print desired pascal triangle.

We need to do little modification to function we wrote in part A, as number of function parameters passed in B is just 1, unlike part A.

(6) For Part ß, we modify our function to consume only I argument le how and we need newline (h) after every line Fumetin i

Add a comment
Know the answer?
Add Answer to:
use scheme program The following pattern of numbers is called Pascal's triangle. The numbers at the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT