number = myfirstfunction (text, freq); // The first function, where "text" is a string, // and "freq" is the array that is filled with data mysecondfunction (number, freq); // The 2:nd function where the value from the previous // function is being used, and the array "freq" is // bring printed.
Chat with our AI personalities
In C++ you would pass a std::array if the array is fixed-length, otherwise you'd use a std::vector. Most object oriented languages will provide some method of passing a self-contained array object to a function. In C and other non-object oriented languages you would pass a reference or pointer to the start address of the array along with a variable indicating the number of valid elements within the array. The array type will determine the size of each element.
In some programming languages, like C, you can pass the new method (or function) an address pointer to the first element in the array. As long as you don't leave the scope of the method the array was created in, the array will remain valid. In other languages that don't support memory addresses, like FORTRAN, it must be done by making the array global.
Method 1: Sort the array in descending order, compare 1st and 2nd if not same , return 2nd if same return -1 Method 2: Find the largest number in the array, initialize another array with dimension 1 less than of original. Copy the array elements from the original array minus the largest element. not select largest from the second array and compare with the previous one if not same return the second largest if same return -1
When a function is nested inside another function, the outer one is the parent, the inner is the child.
A function is a mapping from one set to another such that each element from the first set is mapped onto exactly one element from the second set.