0
Write a Pascal triangle program
3 Antworten
+ 1
Hi Emmanuel, this is not a question.
Also, would you be so kind to tell me why you want an answer to a commonly used exercise that is used for teaching programming while your achievements miss the achievement for completing a single lesson in Solo Learn C++?
+ 1
#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;
}
0
This is a program for Pascal's triangle. Hope this helps you.