Thread: For Loop in C

  1. #1
    Registered User
    Join Date
    Jan 2017
    Posts
    1

    For Loop in C

    Hello every one , i want to do an For loop for this console output.

    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5
    1 2 3 4 5 6
    1 2 3 4 5 6 7
    1 2 3 4 5 6 7 8
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9 10

    And i want have something like this.

    0 1 2 3 4 5 6 7 8 9 10
    1 2 3 4 5 6 7 8 9 10
    2 3 4 5 6 7 8 9 10
    3 4 5 6 7 8 9 10
    4 5 6 7 8 9 10
    5 6 7 8 9 10
    6 7 8 9 10
    7 8 9 10
    8 9 10
    9 10
    10

    It need to have 2 For Loops.
    Can someone script me that in C?.
    I'm new in programming and i dont know how that work.


    Thx.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Forum Guidelines

    We are here to help people who are having specific problems with programming, not to do their work for them.

    You need to make an attempt at figuring this out yourself. If you get stuck, post your code (using code tags) along with specific questions about where you need help.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "...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

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I'll give you some very general tips.

    Your going to need two loops, one outer loop and one inner loop. Both continuation conditions are going to have to either increment to ten or decrement to zero. I would use a FOR loop for this, as while and do-while can be a little harder to implement. Don't forget to print the newline.
    Double Helix STL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-22-2016, 09:08 AM
  2. Replies: 1
    Last Post: 03-28-2015, 08:59 PM
  3. Help - Collect data from Switch loop inside While loop
    By James King in forum C Programming
    Replies: 15
    Last Post: 12-02-2012, 10:17 AM
  4. Replies: 23
    Last Post: 04-05-2011, 03:40 PM
  5. for loop ignoring scanf inside loop
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-17-2007, 01:46 AM

Tags for this Thread