Array question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • minuns
    New Member
    • Apr 2009
    • 2

    Array question

    pls help me here.

    write a function that sums up the even and odd indexed elements of an array of doubles' separately.
    each elements of the array contributes to one of the two sums; depending on whether the index of the elements is even or odd. your function definition should look something like this

    sum(a,n,even_in dex_sum_ptr, odd_index_sum_p tr)
    double a[ ], *even_index_sum _ptr, *odd_index_sum_ ptr;
    int n; /*n is the size of a[ ] * /
    {
    }
  • whodgson
    Contributor
    • Jan 2007
    • 542

    #2
    I think it would be better if you started a new thread as the moderators and experts here think that highjacking someone else`s post is a bit rude; and you should post your effort and indicate where and why you are having trouble.
    rgds,

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      I split the posts and moved them to their own thread indeed. Hijacking a thread is not done: start your own thread for your question.

      kind regards,

      Jos (moderator)

      Comment

      • whodgson
        Contributor
        • Jan 2007
        • 542

        #4
        Well, firstly you have to declare and initialize a type double array[] with a series of doubles. Compile the program at this point and print out the contents of the array to prove that so far all is well.Then you have to declare a double type prototype sum() function.
        After this you have to define the sum() function by giving its body the ability to sum. What arguements would need to be passed to this sum() function? Well certainly the array.
        Write out the seudo code without worrying about getting the syntax correct and when you feel it looks pretty right, type the code and debug it so that it compiles. If you run into problems post your code and identify where you would like assistance.
        hope this helps.

        Comment

        Working...