Question
What is wrong with my code? #include int pascal (int); long factorial(int); int main () { int n; printf (Enter the number of rows you
What is wrong with my code?
#include
int pascal (int); long factorial(int);
int main () { int n; printf ("Enter the number of rows you want to see in the Pascal Triangle: "); scanf("%d",&n); // Reads the size of Pascal Triangle from the user pascal(n); return 0; }
int pascal(int n) { int i,c; int arr[50][50]; for (i = 0 ; i The Pascal triangle can be used to compute the coefficients of the terms in the expansion of (a + b)n. Write a function that creates a two-dimensional matrix representing the Pascal triangle. In a Pascal triangle, each element is the sum of the element directly above it and the element to the left of the element directly above it (if any). A Pascal triangle of size 7 is shown below 10 15 10 20 15 6 In the above example, the first element of row[o] and the first two elements of row[1] are set to 1. Then each of the following rows, up to the maximum size, arc set with a loop as shown in the following pseudocode: Algorithm PascalTriangle i pascal[0][0] 1 2 pascal[1][0] = 1 3 pascal [1][1] = 1 4 prevRow 5 currRow 6 loop (currRow
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started