i have tried to do the pascals law in the following method .....bt i m not getting a triangle shape.could someone help me out in this tight Spot?? here is the code what i have typed...
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
long TRIANGLE(int x,int y);
int main()
{
clrscr();
int lines=0,n;
cout<<"enter how many lines";
cin>>n;
for(lines=0;lines<=n;lines++)
{
for(int i=0;i<lines;i++)
for(int j=0;j<lines-n;j++)
cout<<setw(2)<<" ";
for(j=0;j<=i;j++)
cout<<setw(4)<< TRIANGLE(i,j);
cout<<endl;
}
getch();
}
long TRIANGLE(int x,int y)
{if(x<0||y<0||y>x)
return 0;
long c=1;
for (int i=1;i<=y;i++,x--)
c=c*x/i;
return c;
}