Anonymous

What Are Arrays?

4

4 Answers

Anonymous Profile
Anonymous answered
Arrays are collection of variables that have same name and same data type
Anonymous Profile
Anonymous answered
Arrays are collection of variables that have same name and same data type.

Suppose you want to write a program in which you have to take ten students and their marks in diffrent subjects and then calculate average of marks then you will initialaiz ten variables of student1 and student2...student10.and average variable
then you can print all of them easily. No my point is if you have are asked to write 500 students then what will you do? Obviously you will initialaize 500 variables of student1 and student2...student500 but it is tedeaous you can also do it but if you are now asked to take 5000 students instead of 500 students. Now thats the point where arrays are used.now using arrays you will just initialize an array of size 500 or 5000 and only one loop then you can get your result in just 2 minutes. I hope you will b satisfied.anyway plz reply me.
John Swindells Profile
John Swindells answered
Arrays are basically lists. So instead of a variable being just one of something, it can instead be a list of things.

An associative array is a special kind of list, where you are able to reference each item in the list by a predefined name. For example, if you have a list of telephone numbers, you could use the person's name as the 'key' in the associative array, to reference their phone number. In PHP you would write something like $phone_number = $contacts['John'] to get John's phone number.
Anonymous Profile
Anonymous answered
Think of an array as a list of data items, each item being able to be referenced by its place in the list (array). So the array CITIES could be made up of the items (names in this case) Chicago, Detroit, Madison, and Indianapolis. A program could go through the list and do something with it. This is called a one dimensional array. If one wanted pairs of items, a two dimensional array could be created. And so forth.

An array can also be thought of as a file within a program. Indeed one could populate an array from a file, but an array's contents can also be hard-coded. Or be filled bt prompting the user for the data. And then something is done with it.

Arrays can be sorted, low to high or high to low depending on what's needed. Sometimes the programming/scripting language has this built in, but earlier languages required programmers to that manually.

Answer Question

Anonymous