| 1 | #include <iostream> |
| 2 | using namespace std; |
| 3 | int 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected