![]() |
|
#1
|
|||
|
|||
Understanding passing function through arraysHi there,
I am very Confuse in C++program I took introduction C++ programming 4 years ago so now I forgot everything which I learnet on that time.My question is that. I have to write a program in C++ to use a function by entering upto 10 floating point values and these values should be stored in arrays, and the values should be displayed the user with identifying text: sum of all values,average values I/p, largest values i/p,smallest value I/p. we need to write 2 function getData and processData where get get data recieve 3 parameter list, maximum number, and actual number of values. and processData two parameter-list and current number and do all thing sumand avg, large and small. so that was the program description now my question is that here first of all what is list and I tried to write few lines of codes which are here CPP / C++ / C Code:
Last edited by LuciWiz : 03-Sep-2008 at 07:16.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
||||
|
||||
Re: need help in understanding passing function through arraysYou need to work with "float" data type and not "int" data type.
CPP / C++ / C Code:
Output: Code:
...there is no benefit to using an "int" array. Mexican Bob |
|
#3
|
|||
|
|||
Re: need help in understanding passing function through arraysQuote:
A list is a group of data of the same type which are stored in some sequential fashion so that they can be accessed and manipulted. A simple example would be an array as in this random list of chars: CPP / C++ / C Code:
to a contiguous block of 10 chars in memory. A more advanced example might be an array of arrays or 'list of lists' ...like this 'list' of 3 words: CPP / C++ / C Code:
each point to a block of 10 chars. This too is stored in a contiguous block of memory. You can have a 'list' of any data type: int, float, even structures or classes. A list does not have to be an stored in an array. A 'list' can be allocated as the program runs and so would be stored at non-contiguous memory and so other means used to determine where the members are located (which is for later study). From what I can understand from your description above, your 'list' is to be: Quote:
But like above here are 3 arrays of 10 each except they are in type float: CPP / C++ / C Code:
What you will need to learn to do is pass a pointer to the array (or array member) to the functions along with the sizes of the array. Are you with us so far? Do you understand pointers? Practice by passing a c string (array of type char) to a function and printing it from the function. Last edited by Howard_L : 03-Sep-2008 at 23:21.
|
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| run script command on ns2.26 | newbie06 | Computer Software Forum - Linux | 65 | 19-Aug-2009 08:50 |
| Flex and bison coding | lucky88star | C++ Forum | 5 | 24-Dec-2007 12:57 |
| Need Help with input files. | Efferus | C++ Forum | 2 | 24-Nov-2007 17:19 |
| Arrays as function arguments - return arrays from functions | pisuke | C Programming Language | 2 | 25-Jul-2007 12:03 |
| need help with passing 3 arrays into a function | tommy69 | C Programming Language | 14 | 07-Apr-2004 01:22 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The