Thread: 'For Loop' example

  1. #1
    Registered User
    Join Date
    Nov 2008

    'For Loop' example

    I am learning c for last one week. While learning for loop one of my friend challenged to code a program with two for loop that produce output like below......

    This Is For-loop example:

    * * * *
    * * *
    * *

    I tried it but had to use more for-loops. Any idea

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    What did you try?
    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
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    London, UK
    Quote Originally Posted by milanparmar View Post
    my friend challenged
    It's nice that you're such good friends with your teacher...

    But think about it. You have a certain number of lines and a certain number of asterisks per line. So you need one loop for the number of lines and one for the number of asterisks per line.

    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed