Thread: generate number

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    7

    Post for loop

    Code:
    #include<stdio.h>
    
    //main function..
    int main(void){
    int i,j,k;
    int n=3;
            for(i=0;i<=3;i++) {
                    j=1;
                    while(j<=n) {
                            printf("\t%d",j);
                            j++;
                    }
                    printf("\n");
                    n=n+3;
    
    
    
            }
    
    }
    the output is:
    1 2 3
    1 2 3 4 5 6
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9 10 11 12

    but i want the output as
    1 5
    2 6 9
    3 7 10 12
    4 8 11 13 14 15
    anyone help me using the for loop?..
    Last edited by cheeta; 05-03-2010 at 01:23 AM. Reason: wrong information

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-23-2009, 01:55 PM
  2. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  3. Random number + guessing game trouble
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-08-2007, 03:33 AM
  4. Perfect number...
    By Argo_Jeude in forum C++ Programming
    Replies: 8
    Last Post: 07-12-2005, 01:53 PM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM