# Thread: Multiplication Table using Array.

1. ## Multiplication Table using Array.

Hi, so I'm writing a program that prints out multiplication table using two dimensional array. After i run it i get errors, can some one assist me how to fix them?
Thank you

Code:
```#include <stdio.h>

void multiply( int i, int j);

int main(void)
{
int a;
int i;
int j;
int answer;

int a[ 13 ][13]=
{{ 0,1,2,3,4,5,6,7,8,9,10,11,12},
{  0,1,2,3,4,5,6,7,8,9,10,11,12}};

multiply( i, j);
answer = a;

for ( int i = 0; i <= 13; i++)
for ( int j = 0; j <= 13; j++)
{
a = a[i][j];
printf("x 0 1 2 3 4 5 6 7 8 9 10 11 12");
for ( i = 0; answer <= 26; i++)
{
printf("%-5d", a[i][j]);
}
}

return 0;
}

void multiply( int i, int j )
{
int answer = 0;

for( int i = 0; i <= 13; i++)
{
for( int c = 0; c <= 13; c++)
{
answer = i * c;

}
}
Return answer;
}```

2. You have multiply as a void return type, but include a return - you need to make up your mind what you want the compiler to do.

Also, you're giving answer the value of a, but a is a constant pointer to the base of it's array, and answer is an int.

You should go with multiply, and print from there. use i and c, and forget a[] completely - you don't need it. (Why is that?)

What would happen if you printed up c x i equals answer, right in multiply?

And *please* learn to indent. Reading "flat" code is a PITA.

Popular pages Recent additions