Friday, 14 September 2012

C++ Program to display a Triangle of numbers called the Pascal's Triangle

C++ Program to  display a Triangle of numbers called the Pascal's Triangle, when provided with  the number of rows

 # include <stdio.h>
#include<conio.h>
void main ()
{
int pal[50][50];
int i,j,k,n;
printf("ENTER THE NUMBER OF ROWS : ");
scanf("%d",&n);
for (i=0;i<n;i++)
{
pal[i][0]=1;
pal[i][i]=1;
for (j=1;j<i;j++)
{
pal[i][j]=pal[i-1][j-1]+pal[i-1][j];
}
for (j=1;j<=(n-(i+1));j++)
{
printf (" ");
}
for (k=0;k<=i;k++)
{
printf(" %2d ",pal[i][k]);
}
printf("\n");
}
getch();
}

1 comments:

Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More