Program to print Pascal's Triangle :-
#include<iostream>
#include<conio>
void main()
{
int i,j,k,row;
cout<<"Enter No. Of Rows:";
cin>>row;
for(i=0;i<row;++i)
{
int val=1;
for(k=1;k<=row-i;++k)
{
cout<<" ";
}
for(j=0;j<=i;++j)
{
cout<<val<<" ";
val=val*(i-j)/(j+1);
}
cout<<endl<<endl;
}
getch();
}
No comments:
Post a Comment