1.

Solve : Please explain me?

Answer»

I did write the following C code. I was able to use the TCC complier.
Output is displayed.


C:\>type pas.c

Code: [SELECT]#include<stdio.h>

void main()
{

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

printf("\n\nEnter the no. of rows: ");
scanf("%d",&line);

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

for(x=line-1;x>=0;x--)
printf(" ");
printf(" 1\n\n");

for(n=2;n<=line;n++)
{
for(c=line-n;c>=1;c--)
printf(" ");
pasc(n);
printf("\n");
}


}
void pasc(int n)
{
int R;
long fact(int);
for(r=0;r<=n;r++)
printf("%3ld ",fact(n)/(fact(n-r)*fact(r)));
}

long fact(int v)
{
if(v==1||v==0)
return(1);
else
return(v*fact(v-1));
}Output:

C:\>pas.exe


Enter the no. of rows: 9




Pascal's triangle :
1

1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1

C:\>Quote from: marvinengland on June 20, 2010, 07:40:25 PM

I did not write the C code. I was able to use the TCC complier.
Output is displayed.

I did not write the C code in the post above .
I was able to use the TCC complier.
Output was displayed.


Discussion

No Comment Found