Thread: Drawing a semi-complex shape using loops

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    3

    Drawing a semi-complex shape using loops

    Hello. I am asked to write a C specific code to draw the following shape:


    Drawing a semi-complex shape using loops-programm-png


    The restrictions are, that no arrays can be used. Loops are to be used.
    Now, I'm not quite sure how to perform this. I tried to imagine this as a big rectangle and divide it into four equal parts( i<n/2 && j<n/2) - the first quadrant, etc.

    Any help would be appreciated.

    Also, we are expected to input the "size".

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Can you draw those 4 shapes separately? If no, start from there. If yes, you simply need to print all four of them inside the same loop, by using the appropriate if statements that check at with quadrant you currently are. If N is the total size then the X will be at (0,0), the first square at (N/2,0), the second square at (0,N/2) and the hash at (N/2,N/2).
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    That is a nice simple programming assignment.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-21-2016, 06:02 AM
  2. Drawing a shape into a PGM image
    By Luke O' Mahony in forum C Programming
    Replies: 2
    Last Post: 11-22-2013, 01:46 PM
  3. drawing a square with loops
    By darren78 in forum C++ Programming
    Replies: 10
    Last Post: 05-01-2011, 08:23 PM
  4. Help with drawing a shape in a window
    By Marcos in forum C++ Programming
    Replies: 2
    Last Post: 08-21-2003, 01:21 PM

Tags for this Thread