Sie sind auf Seite 1von 13

The values of any of the elements in an array can be accessed just like the value of a regular variable of the

same
type.
Following the previous examples in which foo had 5 elements and each of those elements was of type int, the name
which can be used to refer to each element is the following:

At some point, we may need to pass an array to a function as a parameter. In C++, it is not possible to pass the entire
block of memory represented by an array to a function directly as an argument. But what can be passed instead is its
address. In practice, this has almost the same effect, and it is a much faster and more efficient operation.
To accept an array as parameter for a function, the parameters can be declared as the array type, but with empty
brackets, omitting the actual size of the array.

C++ program to store and calculate the sum of 5 numbers entered by the user using arrays.
Let's see a simple example of C++ array, where we are going to create, initialize and traverse array.

Let's see an example of C++ function which prints the array elements.

Let's see an example of C++ array which prints maximum number in


an array using function.

Let's see a simple example of multidimensional array which initializes array at the time of declaration.
Let’s see how to declare, initialize and access Three Dimensional Array elements.

This way of initializing is preferred as you can


visualize the rows and columns here.

We are passing two arrays a & b to the function sum (). This function adds the corresponding elements of both the
arrays and displays them.
Push () function is used to insert an element at the back of the queue. The element is added to the queue container
and the size of the queue is increased by 1.

Pop () function is used to remove an element


from the front of the queue (oldest element in the queue). The element is removed to the queue container and the
size
of
the

queue is decreased by 1.
Given a number of integers, add them to the queue and find the size of the queue without using size function.

Empty
()

function is used to check if the queue container is empty or not.


Given a queue of integers, find the sum of the all the integers.

Size () function is used to return the size of the list container or the number of elements in the list container.

The function is used to access the front element of the queue. The element plays a very important role
as all the deletion operations are performed at the front element.
The function is used to access the rear element of the queue. The element plays a very
important role as all the insertion operations are performed at the rear element.
The function is used for interchanging the contents of two containers in reference.
Stack empty () function is used for testing whether the container is empty or not.
The function returns the size of the stack container, which is a measure of the number of elements stored in the
stack.

The
function is used to access the top element of the stack. The element plays a very important role as all the insertion

and deletion operations are performed at the top element.

The function is used for the insertion of a new element at the top of the stack.
The function is used for the deletion of element; the element in the stack is deleted from the top.
The function is used for interchanging the contents of two containers in reference.

Push () function is used to insert an element at the top of the stack. The element is added to the
stack container and the size of the stack is increased by 1.