Arrays
Gapfill exercise
Enter your answers in the gaps. When you have entered all the answers, click on the "Check" button.
What do you mean by passing an array to a function?
Generally we pass values and
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
while
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
a function, likewise we can also
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
arrays to a
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
. You can pass array’s
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
as well as whole array (by just specifying the array name, which works as a pointer) to a
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
.
What is pointer to array?
Array elements can be
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
and manipulated using pointers in C. Using
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
you can easily handle
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
. You can have access of all the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
of an array just by assigning the array’s base address to
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
variable.
How to store user input data into 2D array
We can calculate how many elements a two
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
array can have by using this formula:
The
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
arr[n1][n2] can have n1*n2 elements. The
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
that we have in the example below is having the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
5 and 4. These dimensions are known as
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
. So this
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
has first subscript value as 5 and
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
subscript value as 4.
So the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
abc[5][4] can have 5*4 = 20 elements.
How to pass an entire array to a function as an argument?
In the above example, we have
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
of each array element one by one using a for
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
in C. However you can also pass an entire array to a
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
like this:
Note: The
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
name itself is the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
of first element of that
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
. For example if array name is arr then you can say that arr is equivalent to the &arr[0].
What do you mean by Passing array to function using call by reference?
When we pass the
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
of an array while calling a
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
then this is called function call by
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
. When we pass an
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
as an argument, the function
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
should have a pointer as a
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
to receive the passed
accessed
address
array
calling
declaration
dimensional
dimensions
element
elements
function
loop
parameter
pass
passed
pointer
pointers
reference
second
subscripts
variables
.
Check
OK