im studying C++ and am having a problem with multiplying two arrays of integers. can i get help with setting up a loop that gets the size of the first array and the second array. then multiply the last integer of the second array with all the integers in the first array starting with the last integer of the first array.

help would be a apreciated.

Why bother reinventing the wheel when it's already been done for you...

void mult (int rows, int cols, 
                          int[][] m1, int[][] m2, int[][] m3) {
    for (int i=0; i<rows; i++) {
        for (int j=0; j<cols; j++) {
        int val = 0;
        for (int k=0; k<cols; k++) {
            val += m1[i][k] * m2[k][j];
        }
        m3[i][j] = val;
        }
    }
    }

Could you use sizeof to get the dimensions? I don't know.

im a first year cs student and im trying to multiply two arrays when user inputs integers in an array. is there a way to do this with out using a 2D array. here is the function im working on

int multiply ( int x[], inty[] )
{

im a first year cs student and im trying to multiply two arrays when user inputs integers in an array. is there a way to do this with out using a 2D array. here is the function im working on

int multiply ( int x[], inty[] )
{
for ( int counter = sizeof x-2; counter >= 0; counter--)
}

this function multiplies all digits in the first array with the last digit of the second array. is there a way i can increment the second to the last integer in the first array so that it multiplies 10 to it and a multiplies a 100 to the third and a 1000 to the fourth and so on until the first array reaches 0. i want to do this so i can can store the outputs in another array element and add them all up for an output.

This article has been dead for over six months. Start a new discussion instead.