Write a program to print the Pascal’s - Triangle till n . n is given | CODE WITH SHARAD

Write a program to print the Pascal’s - Triangle till n . n is given

Written by Sharad Raj on 13th of March, 2018

BASIC PROGRAMS   C LANGUAGE PROGRAMS

PROGRAM CODE

**       1**



**     1  1**



**   1   2   1**



** 1   3   3   1**


#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,n,a,z,s;
clrscr();
/* x, y are for loop control and n is to store the input limit*/
printf("Enter the value of n or limit: ");
/*limit implies number second from edge in Pascal's tringle*/
scanf("%d",&n);
printf("\n\n");
s=n;
for(x=0; x=0; z--)
printf(" ");
s--;/* s is for printing the space*/
for(y=0; y<=x; y++)
{
printf("%d ",a);
a=(a*(x-y)/(y+1));
}
printf("\n");
}
getch();
}


Comments


Contact