Introduction
- In this blog, I am going to explain how to print a Pascal triangle.
Software Requirements
- Turbo C++ or C.
Programming
Explanation
- #include < stdio.h >
- long factorial(int);
- int main()
- {
- int i, n, c;
- printf("Enter the number of rows you wish to see in pascal triangle\n");
- scanf("%d", & n);
- for (i = 0; i < n; i++) {
- for (c = 0; c <= (n - i - 2); c++) printf(" ");
- for (c = 0; c <= i; c++) printf("%ld ", factorial(i) / (factorial(c) * factorial(i - c)));
- printf("\n");
- }
- return 0;
- }
- long factorial(int n) {
- int c;
- long result = 1;
- for (c = 1; c <= n; c++) result = result * c;
- return result;
- }
- With the help of programming given above, Pascal triangle can be printed by giving the number of rows by the user.




Ramesh PalaniappanPosted Aug 11, 2016, 9:23 AM
Nice Share
Anu VPosted Aug 1, 2016, 12:21 AM
Nice