123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to Calculate the Pascal triangle.

--------------------------------------------------------------------------------



#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[i][1]=1;
printf("%d",a[i][1]);
j=2;c=3;
while(j<=i)
{
a[i][j]=a[i-1][c-1]+a[i-1][c-2];
printf("%5d",a[i][j]);
c=c+1;
j=j+1;
}
a[i][j]=1;
printf("%d",a[i][j]);
}
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG