Arrays

Gapfill exercise

  
Enter your answers in the gaps. When you have entered all the answers, click on the "Check" button.
What is Array?
An array in C or C++ is a collection of items stored at memory and elements can be accessed using of an array. They are used to similar type of as in the data type must be the same for all elements. They can be used to store collection of data types such as int, , double, char, etc of any type. To add to it, an array in C or C++ can store data types such as the , pointers etc. Given below is the representation of an array.

Why do we need arrays?
We can use variables (v1, v2, v3, ..) when we have a number of objects, but if we want to store a number of instances, it difficult to manage them with variables. The idea of an array is to many instances in one .

What are the advantages of an Array in C?
access of elements using array .
Use of less line of as it creates a single of multiple elements.
Easy to all the elements.
through the becomes easy using a loop.
becomes easy as it can be by writing less line of .

What are the disadvantage of an Array in C?
Allows a number of to be entered which is decided at the time of . Unlike a linked list, an in C is not .
and of elements can be costly since the are needed to be managed in accordance with the new allocation.

Difference between pointer and array in C?
Arrays and are two things (we can check by applying sizeof). The confusion happens because name indicates the of first element and are always passed as (even if we use square bracket).

What is 2D array?
We can have multidimensional arrays in C like and 3D array. However the most popular and frequently used is 2D – two array. In this post you will learn how to , read and write in 2D array along with various other features of it.