Thread: How can I get this asterisk shape?

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    54

    How can I get this asterisk shape?

    Hello,

    I want to draw this type of shape by asterisks using FOR nested loops.

    -------*
    ------**
    -----***
    ----****
    ---*****

    On the left side, "------" these are spaces.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is your idea and have you tried?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    I have tried a lot but wrong output

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Right, so what did you try? What algorithm were you trying to implement?

    If you find this problem too hard, try solving it without the spaces, e.g., print shapes of the form:
    Code:
    *
    **
    ***
    ****
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    But it is possible bcoz it is a task given to me but i didnt know how to solve this problem.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Sure, it's possible. Your teacher clearly isn't expecting you to achieve the impossible.

    Laserlight has made a suggestion on how you might break the problem into smaller parts, that may be solved more easily.

    Beyond that, try describing how you would go about addressing the problem (or sub-problems if you follow laserlight's suggestion). Just saying you don't know won't work here, because we know enough to realise that you will learn nothing if we just give you the answer before there is evidence of effort by YOU.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Asterisk Password
    By adnilsah017 in forum C Programming
    Replies: 4
    Last Post: 05-29-2011, 12:16 PM
  2. pointer initializatin - where to put the asterisk?
    By laczfinador in forum C Programming
    Replies: 9
    Last Post: 01-18-2009, 11:36 AM
  3. Password Asterisk
    By $l4xklynx in forum C Programming
    Replies: 5
    Last Post: 10-30-2008, 03:08 PM
  4. masked with asterisk(*)?
    By ShadeS_07 in forum C Programming
    Replies: 32
    Last Post: 10-25-2008, 12:16 PM
  5. Diamond asterisk
    By P_of_Y in forum C++ Programming
    Replies: 33
    Last Post: 07-22-2006, 09:32 PM