CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: number pattern

  1. #1
    Join Date
    Dec 2010
    Posts
    1

    number pattern

    please help me print this pattern using for loop
    1 2 3 4
    5 6 7
    8 9
    10
    10
    9 8
    7 6 5
    4 3 2 1

  2. #2
    Join Date
    Aug 2008
    Posts
    902

    Re: number pattern

    What's your question? Nobody is going to do your homework for you.

  3. #3
    Join Date
    Oct 2007
    Posts
    132

    Re: number pattern

    So it looks like you just need a counting sequence, but also need to enter a newline after so many numbers are printed. The first line has 4 numbers and on down to 1...so you could accomplish this with a loop that loops through 1-10...you then have a variable that represents the number of numbers you will print on this line...it starts at 4 so your for loop would check each time "if number=number_of_numbers_per_line" then print a carriage return and decrement the "number_of_numbers_per_line" variable...

    You could do this again a second time, but the loop decrements and the number_of_numbers_per line increments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured