``````#include <iostream>
using namespace std;

int answer(int x,int y);          //function proto
int mutab[10][12];                      //two dimentional array declaration
int main()
{
for (int i=0;i<1;i++)        //this will fill 1-10 of the multiplication table
{
for (int h=0;h<10;h++)
{
mutab[h][i]=h+1;

}
}

for (int i=0;i<10;i++)    //this will fill  1x1,1x2,1x3 etc.. to ......10x11,10x12
{
for (int h=1;h<12;h++)
{
mutab[i][h]=h+1;

}
}

/*  After the completion of 1st two FOR loops;
arry 'mutab' will be a multiplication table from 1-10 (until 12) . 10x12 will be the biggest no in table.
simple multiplication table  */

for (int k=1;k<11;k++)   //This for loop should create 1x2=2, 1x3=3 ...10x11=110 , 10x12= 120 etc..

for (int j=1;j<13<j++;)
{
cout<<k<<" x "<<j<<" = " <<answer(k,j)<<endl;

}

system("pause");
}

int answer(int y,int x)   // x and y will be the 2D array address.if we want to multiply 3x2, 3=y , x=2
{

int ans;

ans=mutab[x-1][0]*mutab[x-1][y-1];  // to match the array address, x,y will be reduced by 1 coz
// array address begin from 0.

return ans;

}
``````

line 42: try

now there is another problem . I don't get answers to 11xanything ,12xanything. help

next change to the ff.

at line 5: int mutab[12][12];
at line 10: for (int h=0;h<12;h++)
at line 18: for (int i=0;i<12;i++)
at line 31: for (int …

``````#include <iostream>

using namespace std;

int main()
{

int mult[11][12];

int i,j;

// mult[10][X] * mult[X][12] = ans;

for(i=0;i<10;i++)
{
mult[i][0] = i+1;

}

for(j=0;j<12;j++)
{
mult[10][j]=j+1;
}

for(j=0;j<12;j++)
{
for(i=0;i<10;i++)
{
cout<<"\n"<<mult[10][j]<<" x "<<mult[i][0]<<" = "<<mult[10][j]*mult[i][0];
}
}

}

return 0;
}
``````

## All 5 Replies

for (int j=1;j<13<j++;)

must be for (int j=1;j<13;j++)

this is what went wrong. Now ok !

now there is another problem . I don't get answers to 11xanything ,12xanything. help

line 42: try

now there is another problem . I don't get answers to 11xanything ,12xanything. help

next change to the ff.

at line 5: int mutab[12][12];
at line 10: for (int h=0;h<12;h++)
at line 18: for (int i=0;i<12;i++)
at line 31: for (int k=1;k<13;k++)

``````#include <iostream>

using namespace std;

int main()
{

int mult[11][12];

int i,j;

// mult[10][X] * mult[X][12] = ans;

for(i=0;i<10;i++)
{
mult[i][0] = i+1;

}

for(j=0;j<12;j++)
{
mult[10][j]=j+1;
}

for(j=0;j<12;j++)
{
for(i=0;i<10;i++)
{
cout<<"\n"<<mult[10][j]<<" x "<<mult[i][0]<<" = "<<mult[10][j]*mult[i][0];
}
}

}

return 0;
}
``````

cool.thanks!!

Be a part of the DaniWeb community

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