Print Pascal Triangle in C

Advertisements

Prev Tutorial Next Tutorial

Program to Print Pascal Triangle in C

The concept of pascal triangle is; Pascal's triangle is a set of numbers arranged in the form of a triangle. Each number in a row is the sum of the left number and right number on the above row. If a number is missing in the above row, it is assumed to be 0. The first row starts with number 1. The following is a Pascal triangle with 5 rows.

Pascal's triangle is a triangular array of the binomial coefficients.

print pascal triangle in C print pascal triangle in c

Program to Print Pascal Triangle in C

#include<stdio.h>
#include<conio.h>

void main()
{
int bin,p,q,r,x;
clrscr();
bin=1;
q=0;
printf("\t\t\tDisplay pascal Triangle");
printf("\n\n\t\t     Created By:- Hitesh Kumar");
printf("\n\n\nHow Many Row Do you want to input:");
scanf("%d",&r);

printf("\nPascal's Triangle:\n");

while(q<r)
{
for(p=40-3*q;p>0;--p)
printf(" ");
for(x=0;x<=q;++x)
{
if((x==0)||(q==0))
bin=1;
else
bin=(bin*(q-x+1))/x;
printf("      ");
printf("%d",bin);
}

printf("\n\n\n");
++q;
}
getch();
}

Output

program to print pascal triangle

Simply you can download above code and run on your system. I hope these code are helpful for you.


Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements