'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
    21,629
    What did you try?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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