#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;
}
silvercats 10 Junior Poster
silvercats 10 Junior Poster
silvercats 10 Junior Poster
zeroliken 79 Nearly a Posting Virtuoso
Software guy 6 Junior Poster
silvercats 10 Junior Poster
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.