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

4-2 Please do the coding in C language! 4.2 Remember our famous homework#1 progr

ID: 3814159 • Letter: 4

Question

4-2

Please do the coding in C language!

4.2 Remember our famous homework#1 program? This program draws a box 20 characters in width and 10 characters in height, using a for horizontal line and l' for vertical line. printf ("Using brutal force In printf ("--------------------In"); printf In") printf I In"); printf(" In"); printf( In") printf I "); In"); printf( printf(" In") printf I '') printf("---------------- ---- "); Only println0 is used for this purpose. A good solution could involve a loop, which now you know. So, write the solution using loop Hint: One way to solve this would be by writing a loop to draw top line and nested loops to draw the middle lines and later similar loop like top for the bottom line.

Explanation / Answer

4.2 using while loop

#include <stdio.h>

int main()
{
   int i=1;
  
   printf("using brutal force :");
   printf("------------- ");
   while(i>=8)
   {
  
   printf("| | ");
   i++;
   }
   printf("------------- ");
   return 0;
}

4.3 Using do while

#include <stdio.h>

int main()
{
   int i=1;
  
   printf("using brutal force :");
   printf("------------- ");
   do
   {  
   printf("| | ");
   i++;
   }
   while(i>8);
   printf("------------- ");
   return 0;
}

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