+92 332 4229 857 99ProjectIdeas@Gmail.com

Upper right trianlge (C++)


Upper right trianlge
drawUpperRightTriangle() draws an upper right trianlge and it takes 2 parameters:
noOfLines takes the number of lines.
ch takes the character to be displayed in upper right trianlge.

Code

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

using namespace std;

void drawUpperRightTriangle(int noOfLines,char ch)
{
      for (int i = 0; i < noOfLines; i++)
      {
           for (int j = 0; j <= i; j++)
             cout<<ch;
        
      cout<<endl;
      }
}

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

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

0 comments: