Arrays are the collection of variables of similar data type. For example an int array holds the elements of int types while a float array holds the elements of float types. All arrays consist of contiguous memory locations.
To declare an array, specify a variable name with its data type and the number of elements in square brackets, like int Numbers .
Array index is started from 0 and there is no limit of maximum value.
Exercise Questions on Arrays:
- Find maximum and minimum number in an array
- Input 10 number and find sum and average.
- WAP to find sum of odd numbers, even numbers
- Merge 2 arrays in a sorted order
- Reverse the array list
- Merge 2 arrays uniquely
- Insert, delete an element in an array
- WAP that splits an array into odd and even numbers.
- Input 10 numbers in array and find sum of odd and even numbers separately.
- Find factorial of each number stored in array
Double-Dimensional Arrays or 2d-Arrays
The 2-dimensional arrays are the combination of rows and columns. A 2D array is use to represent matrix.
Exercise Question on 2D-Matrix:
- Input two 3x3 matrix and add them.
- Input two 3x3 matrix and multiple them
- Input 3x3 matrix and transpose it
- Input 3x3 matrix and find sum of all rows, columns and diagonals
- Find whether the input matrix is symmetric or not
- Find the upper and lower triangular matrices