+92 332 4229 857 99ProjectIdeas@Gmail.com

Lower left trianlge (C++)


Lower left trianlge
drawLowerLeftTriangle() draws a lower left trianlge and it takes 2 parameters:
noOfLines takes the number of lines.
ch takes the character to be displayed in the lower lef trianlge.

Code

#include "stdafx.h"
#include "iostream"
#include "conio.h"
#include "iomanip"

using namespace std;

void drawLowerLeftTriangle(int noOfLines,char ch)
{
  for (int m = 1; m <= noOfLines; m++)
  {
     for (int n = 0; n < m-1; n++)
              cout<<" ";

   for (int o = 0; o <= noOfLines - m; o++)
              cout<<ch;
  cout<<endl;
  }
}

int main()
{
       drawLowerLeftTriangle(15,'*');cout<<endl;
      
       _getche();
       return 0;
}

Output
***************
 **************
  *************
   ************
    ***********
     **********
      *********
       ********
        *******
         ******
          *****
           ****
            ***
             **
              *

0 comments: