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();
}

Output:

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

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

M.A Siddiqui

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

Leave a Reply

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