Multiplication Table Program

This is a discussion on Multiplication Table Program within the C Programming forums, part of the General Programming Boards category; Looks like you just need a leading \t in that first line. Code: printf("\t"); // start loops here....

  1. #1
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Looks like you just need a leading \t in that first line.

    Code:
    printf("\t");
    // start loops here.

  2. #2
    Do you C what I C? jamesallen4u's Avatar
    Join Date
    Oct 2011
    Posts
    43

    Multiplication Table Program

    Hello,

    I am creating a program which has the output of a 9 X 9 multiplication table.

    Code:
      
    
    #include <stdio.h>
    
    int main()
    {
        int k,q;
    
        printf("\t\t\t      Multiplication Table\n\n");
    
        for ( k = 0; k < 10; k++ )
    
            if ( k != 0 )
                printf("%3d",k);
                printf("\n");
    
        for ( k = 1; k < 10; k++ ) {
    
             printf("%3d",k);
             
             for ( q = 1; q < 10; q++ )
          
             printf("%3d", k*q);
    
             printf("\n");
    
        }
    
    }
    From that I achieve this output:

    Deleted Image


    The numbers at the very top of the table are misaligned. Is there a way to align the two ones like a normal multiplication table? I tried many things but they all ruined the other numbers. Thanks.
    Last edited by kermi3; 11-18-2011 at 07:31 PM. Reason: User privacy, via request

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,293
    Hint: Use an else statement.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Do you C what I C? jamesallen4u's Avatar
    Join Date
    Oct 2011
    Posts
    43
    Thanks CommonTater and iMalc, both of your suggestions worked.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. multiplication table
    By yatesj05 in forum C Programming
    Replies: 7
    Last Post: 04-17-2011, 02:46 AM
  2. C Multiplication Table
    By trueman1991 in forum C Programming
    Replies: 2
    Last Post: 11-11-2009, 06:58 AM
  3. Multiplication table
    By freddyvorhees in forum C++ Programming
    Replies: 6
    Last Post: 08-02-2008, 11:09 AM
  4. multiplication table
    By SpEkTrE in forum C Programming
    Replies: 2
    Last Post: 12-09-2003, 03:46 PM
  5. multiplication table help
    By cprogstudent in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2002, 05:32 PM

Tags for this Thread


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