Arrays :
An Array is collection of similar data type of elements.
ex : int arr[10];
int ch[10];
Syntax :
int arr[size];
Advantages of Arrays :
1.we can easy traverse the specified number location with the help of subscript operator(nothing but random access is possible).
2.ex : int arr[5] = {11,22,33,44,55};
Suppose we want to access the third element in an array ,simply we can call a[2]
3.Arrays are very helpful, when we handle the sequences of same kind of data.
Disadvantages :
1.It can store only similar type of elements.
ex : int arr[10];
char ch[20];
2.Array size we can't increment or decrement at runtime. so wastage of memory may happens.
ex : char ch[50] = {"hai how r u"};
here only 11 bytes is used,remaining 39 bytes should be waste.
0 comments: