Creating Pascals Triangle in C, C++.
Posted on 2006-04-02
Ok so I have to create a Pascal triangle using a 10*10 Matrix, and the rows and columns displayed will be determined by user input. Obviously the number can't be larger than 10. I need two functions...one that will fill in the correct values to the matrix and another for the user to input the size (less than 10). The matrix should look like this
user input = 4
1 1 1 1
1 2 3 4
1 3 6 10
1 4 10 20
So its a little different than the typical pascal's triangle. This is what I have so far...its the only way I could figure out how to do it, and it prints nicely with a nice triangle shape....but that's not the way "we're supposed to do it." I'm thinking for the first row and column I can create a single loop to place 1's in the top row and another for the first column. Any help is really appreciated.
printf("\n\nEnter the no. of rows: ");
printf("\nPascal's triangle :\n");
void pasc(int n)
long fact(int v)