answersLogoWhite

0

#include<iostream>

void append(std::vector<int>& v, int i){ v.push_back(i); }

int main()

{

std::vector<int> v;

append( v, 100 ); // same as calling v.push_back(100);

return(0);

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

How you pass array elements to a function?

Passing array elements to a function is achieved by passing the individual elements by reference or by value, just as you would any other variable. However, passing the entire array requires that you pass a pointer-to-pointer to the array along with the dimension(s) of the array.


When is it better to pass an entire array of data to a function rather than individual elements?

It is better to do this when the function needs to work on the entire array, rather than on individual elements. However, do not pass the array by value; always pass by reference.


How can arrays be used for inter function communication?

The size of a function can be determined from the size of the array. Arrays and functions are both used in computer programming.


Java program to solve lucky number?

Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.


What are arrays?

Array data structure, an arrangement of items at equally spaced addresses in computer memoryArray data type, used in a programming language to specify a variable that can be indexedAssociative array, an abstract data structure model that generalizes arrays to arbitrary indicesor various kinds of the above, such asBit array or bit vectorDynamic array, allocated at run timeParallel array of records, with each field stored as a separate arraySparse array, with most elements omitted, to store a sparse matrixVariable-length arrayRagged (jagged) array, where the rows have different lengths individuallyor various related concepts:Array processor, a computer to process arrays of data (not to be confused with a processor array)Array programming, using matrix algebra notation in programs (not the same as array processing)Array slicing, the extraction of sub-arrays of an arrayAPL (programming language)or also:Video Graphics Array (VGA), a display adapter and video format, and many variants thereof (EVGA, FWVGA, QVGA, QXGA, SVGA, SXGA, SXGA+, TXGA, UVGA, XGA, XGA+, ...)

Related Questions

How you pass array elements to a function?

Passing array elements to a function is achieved by passing the individual elements by reference or by value, just as you would any other variable. However, passing the entire array requires that you pass a pointer-to-pointer to the array along with the dimension(s) of the array.


How can np.permute be used to rearrange elements in a numpy array?

The np.permute function in numpy can be used to rearrange elements in a numpy array by specifying the desired order of the dimensions. This function allows for reshaping and reordering of the elements within the array based on the specified permutation of dimensions.


When an array name is passed to function in c?

It 's address is received by the function . that any changes in the value of array elements in the function will result in actual change.


When is it better to pass an entire array of data to a function rather than individual elements?

It is better to do this when the function needs to work on the entire array, rather than on individual elements. However, do not pass the array by value; always pass by reference.


What does array map do in php?

The array_map function in PHP loops over each elements of the passed array(s), and runs the given function. It then returns a new array that contains the values returned by each call to the given function.


How can arrays be used for inter function communication?

The size of a function can be determined from the size of the array. Arrays and functions are both used in computer programming.


Java program to solve lucky number?

Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.Look at the definition, http://en.wikipedia.org/wiki/Lucky_number , then create an array of integers and start working on it. The sieve method requires you to eliminate certain numbers; you can either replace the eliminated array elements with a marker, or move the non-eliminated elements towards the beginning of the array (overwriting the eliminated elements), or perhaps copy to a different array - depending on whether you want simplicity in programming (putting a marker, such as 0, is probably easier to program), or efficiency.


Sorting of array through function in java programming?

// the build in sorting functions in Java will sort pretty much any array // of Comparable objects or primitives Arrays.sort(someArray);


An array is a group of what kind of animals?

An array in the context of computer programming is a data structure that stores a collection of elements such as numbers or strings. It does not refer to a group of animals.


What is array literal in as2?

An array literal is a comma-separated list of the elements of an array. An array literal can be used for initializing the elements of an array.


What are arrays?

Array data structure, an arrangement of items at equally spaced addresses in computer memoryArray data type, used in a programming language to specify a variable that can be indexedAssociative array, an abstract data structure model that generalizes arrays to arbitrary indicesor various kinds of the above, such asBit array or bit vectorDynamic array, allocated at run timeParallel array of records, with each field stored as a separate arraySparse array, with most elements omitted, to store a sparse matrixVariable-length arrayRagged (jagged) array, where the rows have different lengths individuallyor various related concepts:Array processor, a computer to process arrays of data (not to be confused with a processor array)Array programming, using matrix algebra notation in programs (not the same as array processing)Array slicing, the extraction of sub-arrays of an arrayAPL (programming language)or also:Video Graphics Array (VGA), a display adapter and video format, and many variants thereof (EVGA, FWVGA, QVGA, QXGA, SVGA, SXGA, SXGA+, TXGA, UVGA, XGA, XGA+, ...)


How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.