Write a C++ Program to display Box shape using for loop.

Write a C++ Program to display Box shape using for loop

Write a C++ Program to display Box shape using for loop.

Object:

Write a C++ Program to display Box shape using for loop. C++ for loop Programs examples.

Code:

#include<iostream>
#include<conio.h>

using namespace std;
const int width=40;
const int height=20;
void main()
{
int i;
cout<<“\n\t\t*********************************************\n”;
cout<<“\t\t\t: Display Box Shape:\n”;
cout<<“\t\t*********************************************\n”;
cout<<“\n\n\t\t”;
for(int i=0;i<width-18;i++)
{
cout<<“||”;
}
cout<<endl;
for(int i=0;i<height;i++)
{
for(int j=0;j<width;j++)
{
if(j==0)
{
cout<<“\t\t||”;
}
cout<<” “;
if (j==width-1)
cout<<“||”;
}
cout<<endl;
}
cout<<“\t\t”;
for(int i=0;i<width-18;i++)
{
cout<<“||”;
}
getch();
}

#include<iostream>
#include<conio.h>

using namespace std;
const int width=40;
const int height=20;
void main()
{
	int i;
	cout<<"\n\t\t*********************************************\n";
	cout<<"\t\t\t:  Display    Box    Shape:\n";
	cout<<"\t\t*********************************************\n";
	cout<<"\n\n\t\t";
	for(int i=0;i<width-18;i++)
	{
		cout<<"||";
	}
	cout<<endl;
	for(int i=0;i<height;i++)
	{
		for(int j=0;j<width;j++)
		{
			if(j==0)
			{
				cout<<"\t\t||";
			}
			cout<<" ";
			if (j==width-1)
				cout<<"||";
		}
		cout<<endl;
	}
	cout<<"\t\t";
	for(int i=0;i<width-18;i++)
	{
		cout<<"||";
	}
	getch();
}

Output:

Write a C++ Program to display Box shape using for loop.

Another Program: Write a program that generates a table of any number

1 thought on “Write a C++ Program to display Box shape using for loop.”

  1. Pingback: Write a program to swap two numbers using pointers.

Leave a Comment

Your email address will not be published. Required fields are marked *