Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program with ONLY main function in it that displays a square box with \"

ID: 3546169 • Letter: W

Question

Write a program with ONLY main function in it that displays a square box with "@" whose side is specified by a variable "side". The value of "side" will be input from the user of your program. For loop is required in this program.


for example,

If side is 4, the program displays


@@@@

@         @

@         @

@@@@


2. Try to move the appropriate coding into a function called "Display" and try to call the function from main to get the same result as problem 1.


3. Try to use both problem 1 and problem 2 to draw the following,

@@@@

@         @

@         @

@@@@

@@@@

@         @

@         @

@@@@


Hint : Think about calling the function defined in problem 2.

Explanation / Answer


int length;
cin>>length;

for(int i =0;i<lenght;i++)
cout<<'@'<<endl;
\the first edge

\for the side edges
for(int i=0;i<length-2;i++)
{
cout<<'@';
for(int j=0;j<(length-2)*2;j++)
{
cout<<' ';
}
cout<<'@'<<endl;
}

\for the last edge
for(int i =0;i<lenght;i++)
cout<<'@'<<endl;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote