pattern


1- C++ PROGRAM TO DISPLAY THE HALF PYRAMID OF *, NUMBERS AND CHARACTER.

PROGRAM:

2- C++ PROGRAM TO PRINT HALF PYRAMID AS USING NUMBERS AS SHOWN IN FIGURE BELOW.

PROGRAM:

 

3- C++ PROGRAM TO PRINT TRIANGLE OF CHARACTERS AS BELOW

PROGRAM:

 

4- C++ PROGRAM TO PRINT INVERTED HALF PYRAMID USING * AS SHOWN BELOW.

PROGRAM:

 

5- C++ PROGRAM TO PRINT INVERTED HALF PYRAMID AS USING NUMBERS AS SHOWN BELOW.

PROGRAM:

 

6- C++ PROGRAM TO DISPLAY THE PYRAMID OF * AND DIGITS. 

PROGRAM: 

 

7- C++ PROGRAM TO PRINT THE PYRAMID OF DIGITS IN PATTERN AS BELOW.

PROGRAM: 

 

8- C++ PROGRAM TO DISPLAY REVERSE PYRAMID. 

PROGRAM:

 

9- C++ PROGRAM TO DRAW PASCAL’S TRIANGLE AS BELOW. 

PROGRAM:

 

10- C++ PROGRAM TO DISPLAY FLOYD’S TRIANGLE.

PROGRAM:

 

11- C++ PROGRAM TO DRAW INVERTED HOLLOW TRIANGLE.

PROGRAM:

 

12.  C++ PROGRAM TO DISPLAY FOLLOWING PATTERN:

PROGRAM:





Star pattern : 1

*
**
***
****
*****
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=1;i<=5;i++)
    {
        for(j=1;j<=i;j++)
        {          
            cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}

Star pattern : 2

*
**
***
****
*****
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;

int 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 << endl;
    }
    return 0;
}

Star pattern : 3

*****
****
***
**
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<iostream>
using namespace std;

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

Star pattern : 4

*****
****
***
**
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;

int 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 <<endl;        
    }
    return 0;
}

Star pattern : 5

*****
*****
*****
*****
*****
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<iostream>
using namespace std;

int main()
{
   
    int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=1; j<=5; j++)
        {
            cout << "*";     
        }
         cout <<endl;   
    }
    return 0;
}

Star pattern : 6

*****
*****
*****
*****
*****
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=1; j<i; j++)
        {
            cout << " ";   
        }
        for(j=1; j<=5; j++)
        {
            cout << "*";   
        }
       cout <<endl;   
    }
    return 0;
}

     


Star pattern 7

*
**
*
*
* * * * *
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
using namespace std;

int main()
{
 int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=1; j<=i; j++)
        {
            if(j==1 || j==i || i==5)
            {
                cout<< "*";
            }
            else
            {
             cout << " ";                
            }
        }
        cout <<endl;
    }
    return 0;
}

Star pattern 8

*
**
*
*
* * * * *
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
using namespace std;

int main()
{
 int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=i; j<5; j++)
        {
         cout << " ";
        }
        for(j=1; j<=i; j++)
        {
            if(i==5 || j==1 || j==i)
            {
             cout << "*";                
            }
            else
            {
               cout << " ";
            }
        }
        cout <<endl;
    }
    return 0;
}

Star pattern 9

*
***
*****
*******
*********
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;

int main()
{
    int i, j, k;
    for(i=1;i<=5;i++)
    {
        for(j=i;j<5;j++)
        {
         cout << " ";
        }
        for(k=1;k<(i*2);k++)
        {
            cout << "*";
        }
        cout <<endl;
    }
    return 0;
}

Star pattern 10

*********
*******
*****
***
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include<iostream>
using namespace std;

int main()
{
    int i, j, k;
    for(i=5;i>=1;i--)
    {
        for(j=5;j>i;j--)
        {
            cout << " ";
        }
        for(k=1;k<(i*2);k++)
        {
            cout << "*";
        }
        cout <<endl;
    }
    return 0;
}

Star pattern 11

*
**
**
**
*********
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=i; j<5; j++)
        {
            cout << " ";
        }
        for(j=1; j<=(2*i-1); j++)
        {
            if(i==5 || j==1 || j==(2*i-1))
            {
             cout << "*";
            }
            else
            {
                cout << " ";
            }
        }

        cout <<endl;
    }

    return 0;
}

Star pattern 12

*********
**
**
**
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=5; i>=1; i--)
    {
        for(j=i; j<5; j++)
        {
            cout<< " ";
        }
        for(j=1; j<=(2*i-1); j++)
        {
            if(i==5 || j==1 || j==(2*i-1))
            {
                cout<< "*";
            }
            else
            {
                cout<< " ";
            }
        }
        
        cout<<endl;
    }
    
    return 0;
}

Star pattern 13

*
**
***
****
*****
****
***
**
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=1; j<=i; j++)
        {
         cout<< "*";            
        }
        cout<<endl;
    }
    for(i=5; i>=1; i--)
    {
        for(j=1; j<i; j++)
        {
            cout<<"*";
            
        }
        cout<<endl;
    }

    return 0;
}

Star pattern 14

*
**
***
****
*****
****
***
**
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
using namespace std;

int main()
{
    int i, j;
    for(i=1; i<=5; i++)
    {
        for(j=i; j<5; j++)
        {
            cout<<" ";
        }
        for(j=1; j<=i; j++)
        {
           cout<<"*";
        }
        cout<<endl;
    }
    for(i=5; i>=1; i--)
    {
        for(j=i; j<=5; j++)
        {
            cout<<" ";
        }
        for(j=1; j<i; j++)
        {
            cout<<"*";
        }
         cout<<endl;
    }

    return 0;
}

Star pattern 15

*
***
*****
*******
*********
*******
*****
***
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
using namespace std;

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

Star pattern 16

*
* *
*    *
*       *
*        *
*       *
*    *
* *
*
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<iostream>
using namespace std;

int main()
{
    int i, j;

    for(i=1; i<=5; i++)
    {
        for(j=5; j>i; j--)
        {
           cout<<" ";
        }
        cout<<"*";
        for(j=1; j<(i-1)*2; j++)
        {
           cout<<" ";
        }
        if(i==1) cout<<endl;
      else cout<<"*"<<endl;
    }

    for(i=4; i>=1; i--)
    {
        for(j=5; j>i; j--)
        {
            cout<<" ";
        }
       cout<<"*";
        for(j=1; j<(i-1)*2; j++)
        {
            cout<<" ";
        }
        if(i==1) cout<<endl;
      else cout<<"*"<<endl;
    }
    return 0;
}

Comments

Popular posts from this blog

Stack

Operation on Single Linked List

EXTRA INFORMATION ABOUT TECHNOLOGY