Question: CMPSC 20 1 Fall 2017 Lab 9 Due by the end of your recitation time On 11/10 /17 Purpose: 2 - D arrays (do not

CMPSC 20

1

Fall

2017

Lab 9

Due

by the end of your

recitation

time

On

11/10

/17

Purpose:

2

-

D arrays

(do not use vectors)

For this lab you are to create a

program

that will produce a 2

-

dimensional Pascal array. A Pascal

array is a square (number of rows = number of columns

) array in which the values in the first

row and in the first column are 1. The other values in the array are the sum of the value

immediately to the left and the value immediately above. For example a 5 by 5 Pascal array

would be

1 1 1

1 1

1 2 3 4 5

1 3 6 10 15

1 4 10

20 35

1 5 15

35 70

Consider the circled value (row 3, column4). It was created by adding the value in row 3,

column 3

(6)

to the

va

lue in

row2, column

4

(4)

.

Create your

program

so it could create up to a 10 by 10

array. Prompt the user to enter how

many rows (same as number of columns) he/she would like the array to contain.

Check to make

sure that the entered number is >= 2 and <= 1

0

.

Use

one

nested loop

to fill the array. Then

use

another nested loop

to print the array. Use appropriate formatting in printing the array so the

numbers line up

.

Do not use the same nested loop to

both

fill and

print

the array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!