Thread: how do i make a square?

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    31

    Question how do i make a square?

    i want a square to disply as my out put
    the user has to enter the width n a character
    the out put should be somthg like this:

    Code:
    ******
    *        *
    *        *
    ******
    can someone help me on this?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    i made a mistake with the square ...it should look like a square!!
    there is a hole in the middle

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Do you know how to program with loops? Digest this:
    Code:
    call DrawHorizontalEdge
    FOR each inner row
       print "*"
       FOR each space needed to achieve desired width
          print " "
       ENDFOR
       print "*"
    ENDFOR
    call DrawHorizontalEdge
    You'll have to work out the details of course. You could also use width fields to eliminate the inner-most for loop, but, one thing at a time .

    gg

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    thnx!
    i dont mean to sound like a sissy but can u break it down some more?

  5. #5
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    more pseudocode follows:
    Code:
    from 0 to n,
      if 0 or (n-1)
        draw the whole line ('*' n times) \n
      else
        draw 1 '*', followed by ' ' (n-2) times, followed by 1 '*' \n
    endfrom

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    31
    thank u!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. program to calculate the square root
    By saszew in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 12:53 PM
  2. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 11:53 AM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  4. Square Root ?!?
    By Tm687 in forum C++ Programming
    Replies: 1
    Last Post: 02-29-2004, 04:38 PM
  5. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM