mercredi 27 juillet 2016

C program skipping digits 8 and 9 when incrementing

I am writing a program in C =

Blockquote function void multi_table(unsigned int xsize, unsigned int ysize) that prints a multiplication table on the screen that has numbers from 1 to 'xsize' on the x-axis, and numbers from 1 to 'ysize' on the y-axis, and products of these numbers in tabular format.

my code is like so:

void multi_table(unsigned int xsize, unsigned int ysize)
{
    for(unsigned int row = 1; row <= ysize; row++){
        unsigned int count = 0;
        for(unsigned int column = row; count < xsize; column+=row){
            printf(" %o ",column);
            count++;
        }
        printf("n");
}

and for some weird reason when I call the function

printf("n--- Multiplication table ---n");
multi_table(5,4);

I am getting this output:

--- Multiplication table ---
 1  2  3  4  5 
 2  4  6  10  12 
 3  6  11  14  17 
 4  10  14  20  24 

I am STUCK, please help

Aucun commentaire:

Enregistrer un commentaire