Hey, I have to write a code which calculates pascals triangle using C. So Far I have the triangle with a right side allignment. As part of the assignment, we actually have to get the triangle to appear as a triangle.
I have the function recursively calling itself as below;
Any suggestions on how I can do this?
I know I need ot use a for loop of some sort to print the spaces...
I have the function recursively calling itself as below;
Code:
int pascal_num (int n, int r)
{
int pnum;
if (r == n || n == 1) {
return 1; }
pnum= (pascal_num (n, r-1) + pascal_num (n-1, r-1) );
return pnum;
}
I know I need ot use a for loop of some sort to print the spaces...
Comment