Thursday , 28 March 2024
Home » Tutorials » C programming » C Program to print Pascal’s Triangle

C Program to print Pascal’s Triangle

Program :

#include <stdio.h>
void main()
{
int num,x,y,a[50][50];
clrscr();
fflush(stdin);

printf("Enter the number of rows: ");
scanf("%d",&num);

printf("\n Pascal's Triangle of Order %d\n\n",num);

for(x=0;x{
for(y=0;y<=x;y++)
{
if(x==y || y==0)
a[x][y]=1;
else
a[x][y]=a[x-1][y-1]+a[x-1][y];
printf("%4d",a[x][y]);
}
printf("\n\n");
}

getch();
}

About Rajeel

I'm Rajeel, a teen blogger from India who loves computers, sports, internet and all other kind of tech stuffs. This blog thing is one of my favourite hobby and the one that eats up much of my time. But Really, I'm loving it :) Find me in G+

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Scroll To Top