0
Write a program to print triangle with justâ three sides to print
(with the help of for loop only)there should not be anything inside the triangle just empty space
2 Answers
+ 3
#include <iostream>
using namespace std;
void drawTriangle(char border, char filler, int length)
{
int start =2;
int base =4;
int i;
for(i=start; i<=length; i++)
{
for(int sp=0; sp<=length-i; sp++)
{
cout << " ";
}
if(i>start)
{
cout << border<< " ";
}
if(i>start)
{
for(int b=base; b<=i; b++)
{
cout <<filler << " ";
}
}
cout << border << " ";
cout <<endl;
}
for (int j = base; j<length+base; j++)
{
cout <<border<< " ";
}
cout << endl;
}
int main()
{
int length =12;
drawTriangle('*',' ',length);
return 0;
}
0
Thank You very much