# include<iostream.h>
# include<conio.h>
void main()
{
clrscr();
int l,b,h,i,j;
cout<<"\n Enter length, breadth, and height resp. : ";
cin>>l>>b>>h;
if(h>=b)
{
for(i=0;i<b;++i)
{
for(j=0;j<l+b+1;++j)
{
if(j==b-i ||(j==(l+b+1-i))|| (i==0 && j>b) || j==l+b)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
for(i=0;i<1+h-b;++i)
{
for(j=0;j<l+b+1;++j)
{
if((i==0 && j<l+1)||j==0||j==l+1||j==l+b)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
for(i=0;i<b;++i)
{
for(j=0;j<l+b+1;++j)
{
if(j==0||j==l+1||j==l+b-i||(i==b-1 && j<l+1))
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
}
else
{
cout<<"\n You have input a width greater than height or/and length."
cout<<"\n Sorry! The program cant complete the task for this condition.";
}
getch();
}
Output:
# include<conio.h>
void main()
{
clrscr();
int l,b,h,i,j;
cout<<"\n Enter length, breadth, and height resp. : ";
cin>>l>>b>>h;
if(h>=b)
{
for(i=0;i<b;++i)
{
for(j=0;j<l+b+1;++j)
{
if(j==b-i ||(j==(l+b+1-i))|| (i==0 && j>b) || j==l+b)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
for(i=0;i<1+h-b;++i)
{
for(j=0;j<l+b+1;++j)
{
if((i==0 && j<l+1)||j==0||j==l+1||j==l+b)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
for(i=0;i<b;++i)
{
for(j=0;j<l+b+1;++j)
{
if(j==0||j==l+1||j==l+b-i||(i==b-1 && j<l+1))
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
}
else
{
cout<<"\n You have input a width greater than height or/and length."
cout<<"\n Sorry! The program cant complete the task for this condition.";
}
getch();
}
Output:
0 Comments