Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void main()
- {
- int x,y,n,a,z,s;
- printf("Enter the limit: ");
- /*limit implies number second from edge in Pascal's tringle*/
- scanf("%d",&n);
- printf("\n\n");
- s=n;
- for(x=0; x<=n; x++)
- {
- a=1;
- for(z=s; z>=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);
- /* cell value for next iteration will be calculated in current iteration as:
- a = [ a * ( row_val - col_val ) ] / ( col_val + 1 ) */
- }
- printf("\n");
- }
- getch();
- }
Add Comment
Please, Sign In to add comment