0

Write a program that displays the outline of a box five characters wide and five characters tall. Use the ‘*’ character for the box outline.
here are my codes:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    printf("%c\v", '*');
    printf("%c\v", '*');
    printf("%c\v", '*');
    printf("%c\v", '*');


    printf("%c\n", '*');
    printf("%c%8c\n", '*','*');
    printf("%c%8c\n", '*','*');
    printf("%c%8c\n", '*','*');


    printf("%c\v", '*');
    printf("%c\v", '*');
    printf("%c\v", '*');
    printf("%c\v", '*');
    printf("%c\v\n", '*');
    system("pause");
    return (0);
}

still it works fine, i can see the outline of the box but together with the character '*' there is an another character annoying me and i dn't know how to remove it. it resembles like the gender symbol for males.

2
Contributors
1
Reply
30
Views
3 Years
Discussion Span
Last Post by Adak
3

Instead of explicitly printing every every * with another line of code, you want to use loops and if statements, etc.

Think more like this, in pseudo code:

get the height and the width of the box, from the user
for each row
   move the cursor along the width of the box
   for each column    
      if the column number is the first, or the last one, 
         print a *

      if the row number is the top or the bottom
         print every column with a *
    next column
    print newline
next row    
This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.