Oct 20, 2018, 01:27 AM

## News:

Build a stunning handcrafted website with IT Acumens

## Calculate the Pascal triangle

Started by OmMuruga, Jan 15, 2009, 04:25 AM

Go Down

#### OmMuruga

##### Jan 15, 2009, 04:25 AM
To calculate the Pascals Triangle for given number .

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10];
int i,j,c,n;
clrscr();
printf("Enter how many lines do you want");
scanf("%d",&n);
a[1][1]=1;
printf("%5d",a[1][1]);
a[2][1]=1;a[2][2]=2;a[2][3]=1;
printf("%d %d %d",a[2][1],a[2][2],a[2][3]);
for(i=3;i<=n;i++)
{
a[1]=1;
printf("%d",a[1]);
j=2;c=3;
while(j<=i)
{
a[j]=a[i-1][c-1]+a[i-1][c-2];
printf("%5d",a[j]);
c=c+1;
j=j+1;
}
a[j]=1;
printf("%d",a[j]);
}
}

#### nandagopal

#1
##### Jan 16, 2009, 04:06 AM

This code works perfectly but little explanation needed !!!!

#2
##### Jun 21, 2015, 06:42 PM
this is easy program to solve this easy with loop

Go Up

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification: