An
array is continuous area in the memory referred by a common name. (or) Array is
a collection of elements related to the same data type ( int, float, double).
Array index starts from zero ends with size-1.
Advantage:-
- Array stores the elements in a continuous memory location. So, retrieving the data from the array is fast.
Disadvantages:-
- An ordinary variable can store a value. For the ordinary variables the memory allocations in randomizing positions. Hence retrieving the data from the ordinary variable is bit slow.
- If you create an array we mention the size. But we may or may not use the complete size. If you didn’t use complete size then reserved memory will be wasted.
- It cannot accept different types of elements like one float, one int, one char etc.
- Each individual data item is referred by specifying the array name followed by one or more subscripts. Each subscript is enclosed with square brackets. Each subscript indicates the position of the element in the array.
Arrays are divided into 3 types.
1. Single
dimensional arrays. or One dimensional arrays
2.Double dimensional arrays
3. Multi dimensional arrays
3. Multi dimensional arrays
1. One dimensional array:-
It is a memory allocation which enable you to store ‘n’ no.of homogeneous mixture of elements in a linear fashion. The array which is using only 1 subscript is known as one dimensional array. In One dimensional array the elements are represented in single row or single column.
Syntax:-Data_type array_name[subscript];
ex:- int a[10];
array declaration, initialization and printing program
It is a memory allocation which enable you to store ‘n’ no.of homogeneous mixture of elements in a linear fashion. The array which is using only 1 subscript is known as one dimensional array. In One dimensional array the elements are represented in single row or single column.
Syntax:-Data_type array_name[subscript];
ex:- int a[10];
array declaration, initialization and printing program

output
output
Write a program read the array elements
if the element is negative come out and print it.
output
Write a program read the array elements
findout the smallest element and print it.
output
Write a program read the array elements, enter the searching element and findout the searching element is found or not in the list.
output
Write a program read array elements and
sort them in ascending order.[Bubble Sort]












No comments:
Post a Comment