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.h>
#include<conio.h>
int main()
{
int i,j,k,s,n;
clrscr();
cout<<"\nenter the no. of rows;";
cin>>n;
if(n%2==0)
{
n++;
cout<<"\nthe no. rows changed to " <<n;
}
s=(n/2)+1;
for(i=1;i<=(n/2)+1;i++)
{
for(j=1;j<=s;j++)
{
cout<<" ";
}
s--;
for(k=1;k<=(2*i)-1;k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run