what is the use of arrays in c
Answers
Answer:C - Arrays. Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Answer:
In C programming array is a derived datatype. Main purpose of array in C programming language is to store multiple values of same datatype.
explanation :
int i=0; char ch=’a’;
in above example variable i can store only one value of only integer type. As well as variable ch can also store only one alphanumeric value.
But in array if we declare array as a integer then we can store n number of integer type of value where n is index of array i. e. int arr[n];
ex: int arr[10];
char ch[10];
in above example we can store 10 integer values in arr variable as well as 10 character string in ch variable.
Advantages of an array:
we can store multiple values of same datatype.
we can perform searching, sorting, insert, delete operations on array.
Disadvantages of an array:
one we declare array as a integer the we can store the values of integer type only not of character or float type.
We cannot store the values more than array limit. for example if we declre arr[10] then we can't store values more than 10.