Showing posts with label pascal pattern. Show all posts
Showing posts with label pascal pattern. Show all posts

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;
}












HackCache ’26: A 48-Hour Online Hackathon Open to Every Student

  Hackathons are often associated with computer science students, experienced developers, and teams that already know exactly what they are...

Popular Posts