Thread: Arrays and functions

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    Arrays and functions

    I've only been learning c for a week or two and i'm currently doing an assignment to find the line of best fit for a number of user set co-ordinates.
    i am having trouble setting up a function to sum one of the columns of a two column array. especially what arguments i'm meant to use.

    any help would be GREATLY appreciated

    Pete

  2. #2
    Logic Junkie
    Join Date
    Nov 2005
    Posts
    31
    Too little information. Can you provide a code snippet?
    -S

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Too little information. Can you provide a code snippet?
    If the OP doesn't even know what arguments to use, probably not.
    i am having trouble setting up a function to sum one of the columns of a two column array. especially what arguments i'm meant to use.
    So you have something like this:
    Code:
    int array[2][number];
    and you have to add all the numbers in array[0] or array[1]? Well, your prototype could look something like this:
    Code:
    int add_col(int array[], int size_of_array);
    
    /* function call */
    int array[2][100];
    printf("%i\n", add_col(array[0], 100));
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. arrays, functions, HELP
    By beginner1 in forum C Programming
    Replies: 4
    Last Post: 05-20-2009, 03:29 PM
  2. Manipulating Character arrays in functions.
    By kbro3 in forum C++ Programming
    Replies: 11
    Last Post: 08-16-2008, 02:24 AM
  3. functions using arrays
    By trprince in forum C Programming
    Replies: 30
    Last Post: 11-17-2007, 06:10 PM
  4. Arrays and Functions
    By KunoNoOni in forum Game Programming
    Replies: 12
    Last Post: 10-04-2005, 09:41 PM
  5. Arrays out-of-bounds in functions only?
    By KneeLess in forum C Programming
    Replies: 5
    Last Post: 11-03-2004, 06:46 PM