Thread: Help!!!

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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.

Popular pages Recent additions subscribe to a feed