0% found this document useful (0 votes)
6 views1 page

C++ Box Pattern Program Example

The document is a C++ program that takes user input for the length of a box and outputs a box shape of asterisks of that length. It uses a for loop to iterate through the total number of characters needed, outputting an asterisk for the edges and corners and spaces otherwise, with a newline after each length of characters. The output is a box made of asterisks of the user-specified length.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

C++ Box Pattern Program Example

The document is a C++ program that takes user input for the length of a box and outputs a box shape of asterisks of that length. It uses a for loop to iterate through the total number of characters needed, outputting an asterisk for the edges and corners and spaces otherwise, with a newline after each length of characters. The output is a box made of asterisks of the user-specified length.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Box Example

============================================
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int length;
cout<<"Enter The Length of the Box: ";
cin>>length;
int total=length*length;

for (int i=1;i<=total;i++)


{
if (i<length||i>total-length||i%length==1)
cout<<"*";
else if (i%length==0)
cout<<"*"<<endl;
else
cout<<" ";
}

getch();
}

[Link]
FARHAN: 03008855006

You might also like