forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPascal2.cpp
More file actions
31 lines (31 loc) · 708 Bytes
/
Copy pathPascal2.cpp
File metadata and controls
31 lines (31 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
int main1()
{
cout << "\t\t\tPascal's triangle\n";
int row = 0, col = 0;
int a[7][7] = {};
a[0][0] = 1; // giving the value for the array with address a[0][0]
for (row = 0; row < 7; row++) // rows
{
for (col = 0; col <= row; col++) // columns
{
// code for the borders of the triangle
// giving to then the value 1
if (col == 0 || row == col)
{
a[row][col] = 1;
cout << " " << a[row][col];
}
// code for the finding the values for the inside numbers of the triangle
else
{
a[row][col] = a[row - 1][col - 1] + a[row - 1][col];
cout << " " << a[row][col];
}
}
cout << endl;
}
system("pause");
return 0;
}