answersLogoWhite

0

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.

User Avatar

Wiki User

10y ago

Still curious? Ask our experts.

Chat with our AI personalities

ReneRene
Change my mind. I dare you.
Chat with Rene
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao

Add your answer:

Earn +20 pts
Q: How do you pass a one-dimensional array to user-defined functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

What are the similarities between exponential linear and quadratic functions?

Of the three functions, all three pass the vertical line test. That is, if you draw a vertical line anywhere on the graph that the function is, that line will only pass through the function once. All three are also invertible functions, which means that there is a function that is capable of "undoing" the original function. And because the functions all pass the vertical line test, they are all able to be differentiated.


How are entire arrays passed from one method to another?

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.


How do you pass structures as a parameter to the functions in c plus plus?

Put their names into the parameter-list.


Is anyone of the six trigonometric functions a one to one?

They are all one-to-one as they all pass the vertical line test.


Why you pass arguments to function in c plus plus?

You pass arguments to functions because that is how you tell the function what you want it to do. If you had, for instance, a function that calculated the square root of something, you would pass that something as an argument, such as a = sqrt (b). In this case sqrt is the function name, b is passed as its argument, and the return value is assigned to a.