I'm having severe difficulty creating a multiplication table. I need to create a multiplication table that looks like this by multiplying i*j
1*1= 1 1* 2=2 1* 3=3 1* 4=4 1* 5=5
2*1= 2 2* 2=4 2* 3=6 2* 4=8 2* 5=10
3*1= 3 3* 2=6 3* 3=9 3 * 4=12 3* 5=15
4*1= 4 4* 2=8 4*3=12 4* 4=16 4* 5=20
5 1= 5 5* 2=10 5*3=15 5* 4=20 5* 5=25
This is what I have. I can get a table of i*j I just need to figure out how to put a for statement that could increment itself 5 times for j and start over and then have i increment by 1.
Code:
#include <stdio.h>
#include "conio.h"
const int num_rows = 5;
const int num_columns = 5;
int main(void)
{
int row, column, i, j;
printf("i*j\t", '*');
for (i= 1; i<=5; i++)
if (i <= 5)
break;
printf( "%d", i);
for (column = 1; column <num_columns; column++)
printf("i*j\t", column);
putchar('\n');
for (i= 1; i<=5; i++)
if (i <= 5)
break;,md
for (row =1; row <num_rows; row++)
{
printf("i*j\t", row);
for(column =1; column < num_columns; column++)
{
printf("i*j\t", row *column);
}
printf("\n");
}
_getch();
return 0;
}
Thanks everyone.