Answer:
Explanation:
#include <iostream>
using namespace std;
int printroofln(int, int);
int printbodyln(int, int);
int main()
{
int hgt=0,odd=0,rhgt=0;
cout<<"Enter the height:";
cin>>hgt;
if ((hgt%2)==1) rhgt=(hgt/2)+1;
else rhgt=hgt/2;
for (int i=0;i<rhgt;i++)
{
printroofln(i,hgt);
}
for (int j=0;j<hgt;j++)
{
printbodyln(j,hgt);
}
return 0;
}
int printroofln(int rfln, int hgt)
{
int id1,id2,hlf=0;
hlf=hgt/2;
if ((hgt%2)==1)
{
id1=hlf-rfln;
id2=hlf+rfln;
}
else
{
id1=hlf-rfln-1;
id2=hlf+rfln;
}
for (int i=0;i<=hgt;i++)
{
if ((id1==i)||(id2==i))
cout<<"*";
else
cout<<" ";
}
cout<<endl;
return 0;
}
int printbodyln(int bln, int hgt)
{
for (int i=0;i<hgt;i++)
{
if ((bln==0)||(bln==(hgt-1))||(i==0)||(i==(hgt-1)))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
return 0;
}