Why we need array? Is array replaces the concept of loop? Write the syntax of array
declaration and initialization with an example.
(and please answer the all questions asked above)
Answers
Answer:
An array is a data structure, which can store a fixed-size collection of elements of the same data 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.
Explanation:
To find:
1) Why we need array?
2) Is array replaces the concept of loop?
3)Write the syntax of array declaration and initialization with an example.
Solution:
1) Array is a collection of similar data type.Whenever we have a requirement of taking input which are all similar we declare and initialize array.
Note*: Array of alphabets is known as string.
2) Yes, array replaces the concept of loop.
3) Syntax of array declaration:
syntax of array declaration is different in different programming languages.
I hereby write syntax of C language:
variable_type Name_of_array[size]
for eg:
INT BRAIN[5]
here BRAIN is an array of integer type,it has one dimensional.
In simple terms we can store 5 integer values in BRAIN.
Syntax for array initialization:
Variable_type Name_array[size]={integer values separated by commas}
The array which declare above will be initialize like this
INT BRAIN[5]={27,12,25,11,5}
Note*: Array can be initialize while declaration:
for eg:
INT BRAIN[ ]={27,12,25,11,5}
Hope it helps you.
To learn more on brainly:
1)Observe the following program very carefully and write the name of those header file(s), which are essentially needed to...
https://brainly.in/question/7427835
2) Define the structure of a function?
https://brainly.in/question/5900878