Star triangles (4 different patterns) || Stars in C++

Triangle No: 1
Triangle No: 1


Triangle No:1
#include<iostream>
using namespace std;
void main()
{

for (int i=1; i<=10; i++) // for the number of rows i = number of row
{
       for (int j=1; j<=10-i; j++) // for space
             cout<<" ";

       for (int k=1; k<=i; k++) // for print the star
             cout<<"*";

             cout<<endl;
}
cout<<endl<<endl;
}

Triangle No: 2
Triangle No:2

Triangle No:2
#include<iostream>
using namespace std;
void main()
{
for (int i=1; i<=10; i++) // number of row
       {
             for (int k=2; k<=i; k++) // for space
                   
             cout<<" ";

             for (int j=10; j>=i; j--) // for print the stars
                    cout<<"*";

                    cout<<endl;               
       }

cout<<endl<<endl;
}

Triangle No: 3
Triangle No: 3

Triangle No: 3
#include<iostream>
using namespace std;
void main()
{
for (int i=1; i<=10; i++) // number of row
       {

             for (int j=1; j<=i; j++) // for print the stars
                    cout<<"*";

                    cout<<endl;               
       }

cout<<endl<<endl;
}

Triangle No: 4
Triangle No: 4

Triangle No: 4
#include<iostream>
using namespace std;
void main()
{
for (int i=1; i<=10; i++) // for row
{
       for (int j=10; j>=i; j--) // for stars
             cout<<"*";
             cout<<endl;
}

cout<<endl<<endl;
}

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System