Help!!!

This is a discussion on Help!!! within the C Programming forums, part of the General Programming Boards category; Write a function called arraysum that takes two arguments: an integer array and the number of elements in the array. ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    12

    Help!!!

    Write a function called arraysum that takes two arguments: an integer array and the number of elements in the array. HAve the function return as its result the sum of the elements in the array.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    So what have you tried so far?

    We don't hand out code... you need to make the first effort.
    Work the solution until you hit problems, post your code and
    we'll see what we can do.

    I will give you one hint through: It involves a for() loop.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    230
    i don' t know though if your array is one or two dimension. But, you must access all the array and each time in the loop have this:
    sum =0;
    loop{
    sum = sum + A[ i ];
    }

    Your opinion?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21