Creating Pascals Triangle in C, C++.

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 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.

void main()

int line,c,n,x;
void pasc(int);

printf("\n\nEnter the no. of rows: ");

printf("\nPascal's triangle :\n");

            printf("   ");
printf("  1\n\n");

            printf("   ");


void pasc(int n)
      int r;
 long fact(int);
                  printf("%3ld   ",fact(n)/(fact(n-r)*fact(r)));
long fact(int v)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Since this is probably a school assignment I will provide a basic algorithm

Declare a 2-dimensional array 11x11
Initialize all cells to 0
Set Array[0][1] to 1
Get the number of rows
Fill row1 - row number
Cell[J][K] = Cell[J-1][K] + Cell[J][K-1]

Print the array


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.