Thread: Having trouble multiplying these arrays...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    29

    Having trouble multiplying these arrays...

    This is really the only segment of code that matters

    Code:
    for (i=0; i<length; i++) {
            for (c=0; c<length; c++) {
                 product[i] = a[i]*a[c];
            }
        }
    I'm trying to multiply the arrays by each other (for example if the array a is [4,6,8] and array b is [5, 7,9] then I want the product array to = [4x5, 6x7, 8x9])
    But it is multiplying them some other way and when I try to do it by hand I only get the answer I think is right , not the one the computer gives. If the rest of the program would help I can post that too thanks.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by UCFuser View Post
    This is really the only segment of code that matters

    Code:
    for (i=0; i<length; i++) {
            for (c=0; c<length; c++) {
                 product[i] = a[i]*a[c];
            }
        }
    I'm trying to multiply the arrays by each other (for example if the array a is [4,6,8] and array b is [5, 7,9] then I want the product array to = [4x5, 6x7, 8x9])
    But it is multiplying them some other way and when I try to do it by hand I only get the answer I think is right , not the one the computer gives. If the rest of the program would help I can post that too thanks.

    Code:
    for (i=0; i<length; i++)
        product[i] = a[i]*b[i];

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    29
    Haha well I guess that was pretty simple thanks

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by UCFuser View Post
    Haha well I guess that was pretty simple thanks
    The really cool stuff usually is....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create and manipulate Terabyte size Arrays with Win32API
    By KrishnaPG in forum Windows Programming
    Replies: 1
    Last Post: 11-05-2009, 04:08 AM
  2. Multiplying Huge numbers in integer arrays
    By invierno in forum C Programming
    Replies: 5
    Last Post: 04-11-2009, 08:40 PM
  3. trouble assigning arrays
    By shintaro in forum C++ Programming
    Replies: 8
    Last Post: 11-21-2008, 08:31 AM
  4. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  5. Manipulating Character arrays in functions.
    By kbro3 in forum C++ Programming
    Replies: 11
    Last Post: 08-16-2008, 02:24 AM