Question: /* * C++ Program to Print Pascal's Triangle */ #include using namespace std; int main() { int rows; cout < < Enter the number of

/* * C++ Program to Print Pascal's Triangle */  #include using namespace std;  int main() { int rows; cout << "Enter the number of rows : "; cin >> rows; cout << endl;  for (int i = 0; i < rows; i++) { int val = 1; for (int j = 1; j < (rows - i); j++) { cout << " "; } for (int k = 0; k <= i; k++) { cout << " " << val; val = val * (i - k) / (k + 1); } cout << endl << endl; } cout << endl; return 0; } $ g++ main.cpp $ ./a.out Enter the number of rows : 5  1  1 1  1 2 1  1 3 3 1  1 4 6 4 1 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!