Thread: Please help me understand this question on c++

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    19

    Please help me understand this question on c++

    hi everyone. i got class test today and i think this question is pretty messed up or am stupid and ignorant. i can write the program in my way but this question i cant understand. i dont need the coding, i just need some explanation. it goes like this

    (i) Write a piece of code to declare a function which will do the following:
    (a) return void
    (b) take as input parameters two arrays of integer values
    (c) take as output parameters the sum of these two arrays into a third array to calculate the average temperatures over the last 10 days.


    (ii) Write a piece of code to define an appropriate function for the above to do a sum of the corresponding values in the two input arrays.

    (iii) Write a piece of code to call the above function from the main function.

    I have written the question exactly how it was written in the question paper. Please explain this to me. thank you
    Last edited by darksifer; 04-14-2011 at 03:12 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I'm not sure what you want.

    You say you don't "need code", yet every statement begins "Write a piece of code"

    > (a) return void
    > (b) take as input parameters two arrays of integer values
    > (c) take as output parameters the sum of these two arrays into a third array to calculate the average temperatures over the last 10 days.
    Is
    void foo ( int array1[], int array2[]

    Can you finish this declaration?
    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.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Well .... you are ignorant (lacking knowledge). I don't equate stupidity with ignorance though - an intelligent person can correct ignorance through effort to learn.

    I agree with you that the questions are very poorly worded too.

    The first question is asking you to declare a function (i.e. provide a prototype). The second is asking you to define (i.e. implement) that function. The third question is asking you to write a main() function that calls the function (eg for test purposes).

    As to what the function is supposed to do: it receives three arguments. Two of those arguments are arrays of integer that supply input data. The other argument is an array of integers that receives output data. The function will write values, based on the two input arrays to the output array. The function returns void.

    The calculations to get from the input arrays to the output array is where the questions are very poorly worded. The teacher has done a poor job writing these questions, although it may not be a good idea to tell him or her that. Let tact win the day.

    I assume each element of the output array is either the sum or the average of corresponding elements (I'm not sure which either - best to ask your teacher). Each of the arrays presumably has ten elements, that are (at a guess) temperature values of some form.
    Last edited by grumpy; 04-14-2011 at 04:27 AM.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    19
    @ grumpy & @ salem Thank you both. I answered the question as i understand it. but was not sure. As you said the question is poorly worded and that made me wonder. i just needed someone to tell me that the question is poorly worded. that all. i did my best.
    Last edited by darksifer; 04-14-2011 at 04:55 AM.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    show us your answers and we'll help you find any problems that may exist

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i dont understand this question i got.
    By cfrye1990 in forum C++ Programming
    Replies: 4
    Last Post: 09-26-2009, 08:40 PM
  2. Question i dont understand
    By muran_pling in forum C++ Programming
    Replies: 4
    Last Post: 06-03-2007, 06:22 AM
  3. I could not understand this question
    By enggabhinandan in forum C Programming
    Replies: 3
    Last Post: 10-22-2006, 05:17 AM
  4. Help me Understand (OpenGL Question)
    By Shamino in forum Game Programming
    Replies: 0
    Last Post: 05-06-2005, 05:29 AM
  5. To understand the question....
    By Forever82 in forum C++ Programming
    Replies: 1
    Last Post: 07-20-2003, 10:11 AM