Quick actions

cmd+k|ctrl+k

Navigation

Languages

pascal triangle

Snippet info

Language

Cpp

Visibility

public

Author

matho.camara

Created

2018-11-08T06:56:59Z

Updated

2018-11-08T07:00:37Z

#include <iostream>
using namespace std;

int main() {
  int n, x, y, c, q;
  cout<<"Pascal Triangle Program\n";
  cout<<"Enter the number of rows: ";
  cin>>n;
  cout<<endl;
  for (y = 0; y < n; y++)
  {
        c = 1;
        for(q = 0; q < n - y; q++)
        {
              cout<<"  ";
        }
        for (x = 0; x <= y; x++)
        {
              cout<<"  "<<c;
              c = c * (y - x) / (x + 1);
        }
        cout<<"\n";
  }
  cout<<"\n";
  return 0;
}
INFO