Pages

100 Contemporary Living Room Designs

Tuesday, September 11, 2012

EQUILATERAL TRIANGLE USING STARS

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

2 comments:

  1. Replies
    1. https://programscpp.blogspot.com/2020/12/c-program-to-print-lower-triangle-using-stars.html

      Delete