C programming how to create multiplication table

Closed
kouki420 Posts 3 Registration date Tuesday September 23, 2014 Status Member Last seen September 24, 2014 - Sep 23, 2014 at 01:50 PM
 BC - Jan 13, 2016 at 09:47 AM
I know there is a lot of answer this question but my is kind of different. I am trying to a multiplication table that gives the product when all pairs of numbers are multiplied. For example, it would look like this input a 3.

Enter the size of the table: 3

0 0 0 0
0 1 2 3
0 2 4 6
0 3 6 9

Another example but with input of 5
0 0 0 0 0 0
0 1 2 3 4 5
0 2 4 6 9 12
0 3 6 9 12 15
0 4 8 12 16 20
0 5 10 15 20 25

The code should the prompt the user for an input and print out the table. I would have to use nested for loops. I know the table will be hard to align but I was given the advice of using %4d in the print statement to right align the values. I found a question with a solution similar to what I want on here. Here's the link to it. https://ccm.net/faq/7392-c-program-to-perform-multiplication Any help would be appreciated. Thanks.
Related:

2 responses

shajahansaju Posts 14 Registration date Wednesday September 24, 2014 Status Member Last seen September 24, 2014 3
Sep 24, 2014 at 03:36 AM
int
main (void){
int i, j;

printf (" |");
for (i = 1; I < 11; ++i)
printf ("%#3d ", i);
printf ("\n");

for (i = 1; I < 64; ++i)
printf ("-");
printf ("\n");

for (i = 1; I < 11; ++i){
printf ("%#2d |", i);
for (j = 1; j < 11; ++j)
printf ("%#3d ", I * j);
printf ("\n");
}
return 0;
}
=================result below=================
| 1 2 3 4 5 6 7 8 9 10
---------------------------------------------------------------
1 | 1 2 3 4 5 6 7 8 9 10
2 | 2 4 6 8 10 12 14 16 18 20
3 | 3 6 9 12 15 18 21 24 27 30
4 | 4 8 12 16 20 24 28 32 36 40
5 | 5 10 15 20 25 30 35 40 45 50
6 | 6 12 18 24 30 36 42 48 54 60
7 | 7 14 21 28 35 42 49 56 63 70
8 | 8 16 24 32 40 48 56 64 72 80
9 | 9 18 27 36 45 54 63 72 81 90
10 | 10 20 30 40 50 60 70 80 90 100
4
kouki420 Posts 3 Registration date Tuesday September 23, 2014 Status Member Last seen September 24, 2014 2
Sep 24, 2014 at 03:44 PM
Thats just a repost of the same answer I posted the link for lol.
0
kamine kaam nnhi kr rha
0
kouki420 Posts 3 Registration date Tuesday September 23, 2014 Status Member Last seen September 24, 2014 2
Sep 24, 2014 at 03:43 PM
No need for help anymore just figured how to do it. Thanks anyways.
2