here's anader program..
the output should be like this..
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
........
and here's d c0de..dunn0 if this is right..
#include<stdio.h>
const int leftcorner=1;
const int rightcorner-=1;
const int topelement=1;
int *pascal trianglr=0;
int buildtriangle(int tmpPascalrow;
{
int prev,curr,next;
int tmpRow, elementIndex=0;
int buffer=0;
if(tmpPascalRow==1)
{pascalTriangle[0]=topElement;
return 1;
}
pascalTriangle[0]=leftcorner;
pascalTriangle[1]=rightCorner;
for(tmpRow=3;tmpRow<=tmpPascalRow;tmpRow++)
{
pascalTriangle[0]=leftCorner;
pascalTriangle[tmpRow-1]=rightCorner;
buffer=leftCorner;
for(elementIndex=1;elementIndex<tmpRow-1;elementIndex++)
{
buffer=pascalTriangle[elementindex];
pascalTriangle[elementIndex]+=buffer;
}
}
}
int main();
{
char inputbuffer[10];
int pascalRow=0;
int Index;
fputs ("Enter the number of rows required:", stdout);
fgets (inputBuffer, sizeof (nputBuffer), stdin);
//fflush(stdin);
pascalRow=atoi (inpurBuffer);
pascalTriangle=(int*) callor (pascalRow, sizeof (int) );
biuldTriangle (pascalRow);
for(Index=0;index<pascalRow;index++)
printf("%\t", pascalTriangle[index]);
getchar();
return 0;
}
seeif it works...
thanx..n_n