Monday, April 25, 2022

this program will print the pascal pattern upto inputted rows

 #include <iostream>

using namespace std;
class pasc
{
public:
int coef=1;
    void pasca(int rows)
    {
        system("cls");
        for (int i = 0; i < rows; i++)
        {
            for (int space = 1; space <= rows - i; space++)
            {
                cout << " ";
            }
            for (int j = 0; j <= i; j++)
            {
                if (i == 0 || j == 0)
                {
                    coef = 1;
                }
                else
                    coef = (coef * (i - j + 1)) / j;

                cout << coef << " ";
            }
            cout << endl;
        }
    }
};
int main()
{
    int rows;
    system("cls");
    cout << "enter no. of rows for pascal triangle pattern\n";
    cin >> rows;
    pasc a;
    a.pasca(rows);

    return 0;
}












No comments:

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts