Thread: Using Functions To Create A Rectangle

  1. #1
    Registered User
    Join Date
    Nov 2021

    Using Functions To Create A Rectangle

    Hello, I am extremely new to programming and up until then our assignments in class have been fairly easy, but recently I was thrown one that I am having an immense amount of trouble understanding.

    The assignment consists of using characters to form the rectangle.
    L upper left corner
    R upper right corner
    t top and bottom
    s left and right side
    l lower left corner
    r lower right corner

    I've made the first function in which it prompts for a height and a width, but I am just having an extremely hard time using a for loop to actually make this box using the characters. I apologize for not having any code to in regards to this section, but any help is appreciated!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    How about starting with a rectangle like this?

    If you can manage that, you're half-way there, and have something to build on.

    Learning how to break problems down into manageable steps is a vital skill. Now would be a good time to start learning how to do it.

    Real problems are not solved by staring at the question, then boom, the answer.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2021
    Break it down in small pieces.

    draw_rectangle(x, y)
    - draw ul corner
    - draw top line
    - draw ur corner
    - for loop
    - draw left side
    - draw right side
    - draw bl corner
    - draw bottom line
    - draw br corner

    Think about where the cursor is, and where it has to be, and how to get it there. Your options are printing solid characters, printing spaces, and printing newlines.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create a rectangle with ASCII code.
    By aiodev in forum C Programming
    Replies: 5
    Last Post: 03-08-2019, 09:57 PM
  2. C program to create rectangle
    By Mark Cohen in forum C Programming
    Replies: 28
    Last Post: 07-19-2013, 10:54 AM
  3. Functions which create objects.
    By Swerve in forum C++ Programming
    Replies: 4
    Last Post: 01-28-2010, 04:02 AM
  4. How to Create .H files and use Assembler functions?
    By luisvalencia in forum C Programming
    Replies: 7
    Last Post: 04-10-2005, 11:47 PM
  5. create and display functions
    By jamie85 in forum C Programming
    Replies: 8
    Last Post: 03-19-2004, 07:19 AM

Tags for this Thread