I have to make a multiplication table. The program works correctly but I need to put the numbers multiplied in the array also. EX.
x 0 1 2 3 4 5 6 7 8 9 10 11 12
0
1 answers
2
3
4
5
6
7
8
9
10
11
12

I need to print out the outside numbers with the products. Any suggestions on the code?

#include <stdio.h>
#define COLUMN_SIZE 13 //define the column array size
#define ROW_SIZE 13 //define the row array size

int main (void) //main function
{

int i, j; //counters

int column[COLUMN_SIZE] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; //column array
int row[ROW_SIZE] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; //row array
int product[ROW_SIZE][COLUMN_SIZE] = {{},{}}; //product array

        for(int i=0; i<ROW_SIZE; i++){ //for loop to cycle through row array

                for(int j=0; j<COLUMN_SIZE; j++){ //for loop to cycle through column array

                        product[i][j] = row[i] * column[j]; //equation
                        printf("%d", product[i][j]); //prints product array

                } //end column array for loop

                printf("\n"); //new line

        } //end row array for loop

return 0; //successful termination

} //end main function

Recommended Answers

All 3 Replies

When you say the outside numbers you mean the numbers that are going to be multiplied together like a standard multiplication table?

Yes, the current program prints the answers but not what is multiplied by what to get the answers.

Make line 19;

 ("%4d", product[i][j]); //prints product array

So that you have equal space between you answers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.