How to make pascal's triangle in C++
Please Show me the code
Answers
Answered by
1
Pascal Triangle in c++
/*
* C++ Program to Print Pascal's Triangle
*/
#include<iostream>
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;
}
PLZ MARK BRAINLIEST
IT TOOK TIME......
Similar questions