Saturday, August 21, 2010

Article | C- Program To Generate Pascal's Triangle

C- Program To Generate Pascal's Triangle. Simple Program. Without Using any string funcitons

  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int b,p,q,r,x;
  6. clrscr();
  7. printf("Enter the no. of rows : ");
  8. scanf("%d",&r);
  9. b=1;
  10. q=0;
  11. printf("\n\t\t\tPACSCAL'S TRINGLE\n");
  12. printf("\t\t\t-----------------\n");
  13. while(q<r)
  14. {
  15. for(p=30-3*q;p>0;p--)
  16. printf(" ");
  17. for(x=0;x<=q;x++)
  18. {
  19. if(x==0||q==0)
  20. b=1;
  21. else
  22. b=(b*(q-x+1)/x);
  23. printf("%6d",b);
  24. }
  25. printf("\n");
  26. q++;
  27. }
  28. getch();
  29. }
Loading...

Comments :

0 comments to “ C- Program To Generate Pascal's Triangle ”

Subscribe

Enter your email address:

Followers

Chicklets

My Zimbio