C++ program to print an equilateral triangle using stars.
#include<iostream.h>
#include<conio.h>
void main()
{
int j,i,k,l;
char c;
clrscr();
do
{
cout<<"Enter the number of stars in the base..";
cin>>k;
for (i=1;i<=k;i++)
{
for(l=0;l<(k-i);l++)
cout<<" ";
for (j=0;j<i;j++)
cout<<"* ";
cout<<endl;
}
cout<<"\nWant to try more..(y/n)\n";
cin>>c;
}
while(c=='y');
getch();
}
OUTPUT
#include<iostream.h>
#include<conio.h>
void main()
{
int j,i,k,l;
char c;
clrscr();
do
{
cout<<"Enter the number of stars in the base..";
cin>>k;
for (i=1;i<=k;i++)
{
for(l=0;l<(k-i);l++)
cout<<" ";
for (j=0;j<i;j++)
cout<<"* ";
cout<<endl;
}
cout<<"\nWant to try more..(y/n)\n";
cin>>c;
}
while(c=='y');
getch();
}
OUTPUT
how to print a lower triangle
ReplyDeletehttps://programscpp.blogspot.com/2020/12/c-program-to-print-lower-triangle-using-stars.html
Delete