The goal of Part 2 is to make the side length of the \"box\" variable. Write two
ID: 3752784 • Letter: T
Question
The goal of Part 2 is to make the side length of the "box" variable. Write two functions called border and middle-one for drawing the horizontal borders (i.e., top and bottom horizontal rows of the box) and one for drawing the middle rows. The functions border and middle have one parameter called size, which is the side length of the box (i.e., the number of characters used to draw one side of the box). Then a write a function called box, which calls the functions border and middle to draw the variable size box. The main function is to call the function box twice with size arguments of 5 and 7, respectively, to produce the following output onto the console window:Explanation / Answer
#include <stdio.h>
void border(int n){
int i;
for(i = 0; i < n; i++)
printf("*");
printf(" ");
}
void middle(int n){
int i, j;
for(j = 0; j < n-2; j++){
printf("*");
for(i = 0; i < n-2; i++)
printf("-");
printf("*");
printf(" ");
}
}
void box(int size){
border(size);
middle(size);
border(size);
}
int main(void) {
box(5);
box(7);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.