0% found this document useful (0 votes)
214 views14 pages

All Star Pattern Programs in C

Uploaded by

eieimon eem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
214 views14 pages

All Star Pattern Programs in C

Uploaded by

eieimon eem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

All Star Pattern Programs In C++ Language

In this article, I have explained the list of all Star (*) pattern programs in c++ programming
language. I have used DEV-C++ compiler for debugging purpose. But you can use any C++
programming language compiler as per your availability.

Star Pattern Programs In C++ Language

Star pattern : 1
*
**
***
****
*****
#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

#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
*****
****
***
**
*
#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
*****

****

***

**

#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
*****
*****
*****
*****
*****
#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

#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
#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

#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

#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

#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
#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
#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
*
**
***
****
*****
****
***
**
*
#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

#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
#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

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

You might also like