CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
int main() {
//you need to enter two inputs : no. of rows in the triangle and a character and see the magic
int r,n,k=0;
char ch ='*';
cin>>r;
cin>>ch;
if (!r)
cout<<" Its a fool proof program. Try again";
else
{ n=r-1;
cout<<"\n\n\t\t\t";
for (;n;--n)
{ for (int i=1;i<=n;++i)
cout<<" ";
cout<<ch;
if (k)
{ for (int j=1;j< (2*k);++j)
cout<<" ";
cout<<ch;}
cout<<"\n\t\t\t";
++k;
}
for (int c=1;c< (2*r);++c)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run