'For Loop' example

This is a discussion on 'For Loop' example within the C Programming forums, part of the General Programming Boards category; I am learning c for last one week. While learning for loop one of my friend challenged to code a ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    1

    '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
    Location
    Singapore
    Posts
    23,616
    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
    Location
    London, UK
    Posts
    894
    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.

    QuantumPete
    "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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21