Thread: Still having a problem printing flush right

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    8

    Still having a problem printing flush right

    I have been working on this program for five hours trying to get the star pattern to print flush right can anyone help??? This is what my program looks like.

    for( space = 9; space >= 0; space-- )
    printf( " " );
    {
    for( numline = 1; numline <= 10; numline++ )
    {
    for( numstar = 1; numstar <= numline; numstar++ )
    {
    printf( "*" );
    }
    }
    }

    The program will only print spaces for the first line of the pattern.
    Any help would be appreciated.
    The patterns I am trying to print are attached. Thank you!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well this is what your code looks like formatted
    Code:
        for( space = 9; space >= 0; space-- ) 
            printf( " " ); 
        { 
            for( numline = 1; numline <= 10; numline++ ) 
            { 
                for( numstar = 1; numstar <= numline; numstar++ ) 
                { 
                    printf( "*" ); 
                } 
            } 
        }
    I think you need something like
    Code:
    for ( numline = 1; numline <= 10; numline++ ) 
    {
      for ( space = .... you do this
      for ( numstar = .... you do this as well
      printf( "\n" );
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem in message handling VC++
    By 02mca31 in forum Windows Programming
    Replies: 5
    Last Post: 01-16-2009, 09:22 PM
  2. Replies: 1
    Last Post: 06-07-2006, 09:42 AM
  3. Small problem with printing elements of an array
    By DLR in forum C Programming
    Replies: 17
    Last Post: 03-09-2006, 06:57 PM
  4. Flush problem
    By Furms in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 08:09 PM
  5. problem with printing a structed array using for loop
    By Prezo in forum C++ Programming
    Replies: 2
    Last Post: 09-15-2002, 09:00 AM