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

link. EDIT: Your code can not be compiled, remove the errors.

I have Made a new program..but still there is a error declaration...
i realy nid this program tomorrow so pls help me....re check

#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));
}

in pasc(int):

long fact(int);

That declaration of a function should me in main() where you declare pasc(int)

in pasc(int):

That declaration of a function should me in main() where you declare pasc(int)

what should i put then??

the problem here is

}
  long fact(int v)
{

what should i replace?? The expression is Syntax in Function Main..
pls help

As I said:

You are trying to declare the function fact(int v) inside the function pasc(int). That's not possible...

your program should start like this:

int main()
{
 
void pasc(int);
long fact(int);
int line,c,n,x;
 
//blabla
}

and then delete the line

long fact(int);

from void pasc(int)

I have Made a new program..but still there is a error declaration...
i realy nid this program tomorrow so pls help me....re check

Why should we have to check your code? You should be able to tell if it works or not. And then if you have a problem, you can create a thread for that problem. If you want someone to do your testing for you, you better start making offers for payment.

That said, the code seems to work fine. At least, it compiles and runs correctly (though I only did 1 trial) on VS2005, though I was surprised by that. Few notes:

void main() // should be int main(), as per any standard of C or C++
{
    int line,c,n,x;
    void pasc(int); // don't declare a function within a function. 
                      // Declare it before main() instead.
    // ...rest of the code
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.