ECE 220 MP3 – Pascal’s Triangle

$35.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (4 votes)

Print a row in Pascal’s triangle

In this MP, you are going to implement a C program to print a row in Pascal’s triangle. A Pascal’s triangle is an array that consists of binomial coefficients and the figure below shows the first five rows of
Pascal’s triangle.

A row in the Pascal’ triangle contains all the coefficients of expanding the polynomial , where corresponds to the index of row in Pascal’s triangle.
Details
We refer the binomial coefficient in row by and the coefficient can be computed by following formula :
and . Note that the both and start from “0” and
The program first asks the user to enter a row index (this part has been provided to you) and your task is to calculate all coefficients in that row and
use the standard function printf to print out the coefficients. Refer to : http://www.cplusplus.com/reference/cstdio/printf/ for using printf.
The output should have a space between successive numbers, for example:
As the coefficients are integral, you should NOT use float or double to store the coefficients. Instead, to prevent the number overflow during computing,
you can use unsigned long for the coefficients.
Building and Testing
To compile your program, type the following command:
The -Wall turns on compiler’s warning messages and you have to fix all warnings and errors in compilation.
If the compilation succeeds, you will get a binary called mp3. To execute your program, type :
Here are some sample outputs for verifying your program:
 MP3 assignment is due on Saturday, Sept 30, by 10pm in your svn repository.
(1+ x)n n
kth nth ( )n
k
( ) = = = n
k
n!
k!(n − k)!
n ∗(n − 1) ∗(n − 2) ∗⋯ ∗(n − k + 1)
1∗2∗3∗⋯ ∗k ∏
i=1
k n + 1− i
i
( ) = 1 ∀n ≥ 0 n
0 k n 0≤ k ≤ n
gcc -Wall -g mp3.c -o mp3
./mp3
Hidden test cases will be used for grading. The input row index will be 40.
Grading Rubric
Functionality (90%)
The program outputs the correct results for various inputs.
Style, comments, clarity, and write-up (10%)
Comments and Style – 5%
Intro Paragraph – 5%
If your code does not compile you will get 0.

No labels