MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / main1

Function main1

Lab_09/Pascal2.cpp:3–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <iostream>
2using namespace std;
3int main1()
4{
5 cout << "\t\t\tPascal's triangle\n";
6 int row = 0, col = 0;
7 int a[7][7] = {};
8 a[0][0] = 1; // giving the value for the array with address a[0][0]
9 for (row = 0; row < 7; row++) // rows
10 {
11 for (col = 0; col <= row; col++) // columns
12 {
13 // code for the borders of the triangle
14 // giving to then the value 1
15 if (col == 0 || row == col)
16 {
17 a[row][col] = 1;
18 cout << " " << a[row][col];
19 }
20 // code for the finding the values for the inside numbers of the triangle
21 else
22 {
23 a[row][col] = a[row - 1][col - 1] + a[row - 1][col];
24 cout << " " << a[row][col];
25 }
26 }
27 cout << endl;
28 }
29 system("pause");
30 return 0;
31}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected