Ad

 c++ pattern programs 1




#include <iostream.h>
using namespace std;
int main()
{
int rows;
    cout << "Enter number of rows: ";
    cin >> rows;
    for(int i = 1; i <= rows; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << "* ";
        }
        cout << "\n";
    }
    return 0;
}

Output--


*

* *

* * *

* * * *

* * * * *  






c++ pattern programs 2


#include <iostream.h>
using namespace std;
int main()
{
int rows;

    cout << "Enter number of rows: ";
    cin >> rows;

    for(int i = rows; i >= 1; --i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << "* ";
        }
        cout << endl;
    }
    
    return 0;
}


Output--





c++ pattern programs 3

#include<iostream.h>

using namespace std;

#include<conio.h>

void main()

{

int i, j, k;

for(i=5;i>=1;i--)

{

for(j=1;j<i;j++)

{

cout<<" ";

}

for(k=5;k>=i;k--)

{

cout<<"*";

}

cout<<"\n";

}

getch();

}

 

Output--




c++ pattern programs 4


#include<iostream.h>

using namespace std;

#include<conio.h>

void main()

{

int i, j, k;

for(i=5;i>=1;i--)

{

for(j=5;j>i;j--)

{

cout<<" ";

}

for(k=1;k<=i;k++)

{

cout<<"*";

}

cout<<"\n";

}

getch();

}

Output--



c++ pattern programs 5

#include <iostream.h>
using namespace std;

int main()
{
    int space, rows;

    cout <<"Enter number of rows: ";
    cin >> rows;

    for(int i = 1, k = 0; i <= rows; ++i, k = 0)
    {
        for(space = 1; space <= rows-i; ++space)
        {
            cout <<"  ";
        }

        while(k != 2*i-1)
        {
            cout << "* ";
            ++k;
        }
        cout << endl;
    }    
    return 0;
}

Output--





c++ pattern programs 6

#include <iostream.h>

using namespace std;

int main()

{

    int rows;

    cout << "Enter number of rows: ";

    cin >> rows;

    for(int i = rows; i >= 1; --i)

    {

        for(int space = 0; space < rows-i; ++space)

            cout << " ";

        for(int j = i; j <= 2*i-1; ++j)

            cout << "* ";

        for(int j = 0; j < i-1; ++j)

            cout << "* ";

        cout << endl;

    }

    return 0;

}

Output--





c++ pattern programs 7

 #include<iostream>

using namespace std;

int main()

{

int n, s, i, j;

cout << "Enter number of rows: ";

cin >> n;

for(i = 0; i <= n; i++)

{

for(s = n; s > i; s--)

cout << " ";

for(j=0; j<i; j++)

cout << "* ";

cout << "\n";

}

for(i = 1; i < n; i++)

{

for(s = 0; s < i; s++)

cout << " ";

for(j = n; j > i; j--)

cout << "* ";

cout << "\n";

}

return 0;

}

Output--





Download c++

Helping all of you to make us happy How To Make c plus plus program to print pyramid pattern.how did you feel about us

Post a Comment

Previous Post Next Post