This is a Cpp Program which prints pascals triangle based on the input given.
Download Code PROGRAM :
Download Code OUTPUT :
Pascals Triangle |
#include <iostream> using namespace std; int main() { int i,j,x,n,s; cout << "Enter number of lines[height of triangle] : \t"; cin >> n; for(i=0; i<=n; i++) { x=1; for(s=1; s<=n-i; s++) cout << " "; for(j=1; j<=i+1; j++) { cout << " " << x; x=x*(i-j+1)/j; } cout << "\n"; } return 0; }
Cpp Program to print pascals triangle |