/* Program to enter order of the matrix and print stars*/
#include<iostream.h>
#include<conio.h>
main()
{
int m,n,i,j;
cout<<"\n Enter order of Matrix m*n";
cin>>m>>n;
cout<<"\n";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<" *";
}
cout<<"\n";
}
getch();
}
/* Program to print lower left triangle of stars */
#include<iostream.h>
#include<conio.h>
main()
{
int i,j;
cout<<"\n";
for(i=0;i<10;i++)
{
for(j=i;j<10;j++)
{
cout<<" *";
}
cout<<"\n";
}
getch();
}
/* Program to print lower right star triangle */
#include<iostream.h>
#include<conio.h>
main()
{
int i,j,k;
cout<<"\n";
for(i=0;i<=6;i++)
{
for(j=6;j>i;j--)
{
cout<<" ";
}
for(k=j;k>=1;k--)
{
cout<<"*";
}
cout<<"\n ";
}
getch();
}
/* Program to print star triangle */
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
int i,j,k;
cout<<"\n";
for(i=0;i<=10;i++)
{
for(j=10;j>i;j--)
{
cout<<" ";
}
for(k=j*2;k>0;k--)
{
cout<<"*";
}
cout<<"\n"<<setw(20);
}
getch();
}
C++ Program to Print Triangle of Stars
ReplyDeletePrint triangle of stars is depend of two concept, first you need outer loop for line break and inner loop for increment and decrements.
This comment has been removed by the author.
ReplyDeleteSame Programs Like This
ReplyDelete- https://kabeermukhi.blogspot.com/search?q=pattern