Upper left trianlge
drawUpperLeftTriangle() draws an upper left trianlge and it takes 2 parameters:
noOfLines takes the number of lines.
ch takes the character to be displayed in upper left trianlge.
Code
#include "stdafx.h"
#include "iostream"
#include "conio.h"
#include "iomanip"
using namespace std;
void drawUpperLeftTriangle(int noOfLines,char ch)
{
for (int m = 1; m <= noOfLines; m++)
{
for (int n = 0; n < noOfLines - m; n++)
cout<<" ";
for (int o = 1; o < m + 1; o++)
cout<<ch;
cout<<endl;
}
}
int main()
{
drawUpperLeftTriangle(15,'*');cout<<endl;
_getche();
return 0;
}
Output
*
**
***
****
*****
******
*******
********
*********
**********
***********
************
*************
**************
***************
0 comments:
Post a Comment