Nested loops

This is a discussion on Nested loops within the C# Programming forums, part of the General Programming Boards category; Hi, I have a problem about nested loops in c#. I think this forum is about c and c++. But ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    Unhappy Nested loops

    Hi,
    I have a problem about nested loops in c#. I think this forum is about c and c++. But at least you may write its algorithm. The problem is to print :
    1 2 3
    2 3 4
    3 4 5
    4 5 6
    Thanks a lot.

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    225
    Take a look at this program(Assuming That N is 5). It may help you. Btw, my suggestion would be if you can't write such easy programs you should learn C first. Directly jumping to C# is not a good idea

    Code:
    #include <stdio.h>
    
    #define N 5
    
    int main(void)
    {
     int i,j,k;
     for(i=1;i<=N;i++)
     {
    	k=i;
    	for(j=1;j<=3;j++)
    		printf("%d ",k++);
    	printf("\n");
     }
     return 0;
    }

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    Smile

    Thank you.
    I know it is an easy one but numbers confuse my mind. I can make any shape with stars about nested loops . I will make more examples about them. Thank you again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested For loops
    By Chaplin27 in forum C++ Programming
    Replies: 1
    Last Post: 03-09-2005, 10:12 AM
  2. Evaluation of nested loops
    By Mister C in forum C Programming
    Replies: 2
    Last Post: 08-13-2004, 02:47 PM
  3. nested for loops
    By akub3 in forum C Programming
    Replies: 2
    Last Post: 04-01-2004, 06:21 AM
  4. nested for loops and bank account interest help!!
    By webvigator2k in forum C++ Programming
    Replies: 1
    Last Post: 04-07-2003, 09:03 PM
  5. Nested for loops
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 02-12-2002, 10:25 AM

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